Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
implement variables.tf and assign input variables in module scope
Browse files Browse the repository at this point in the history
  • Loading branch information
MGTheTrain committed Apr 1, 2024
1 parent a8f033a commit 9d7c676
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,14 @@ jobs:
working-directory: ./terraform/envs/${{ github.event.inputs.ENVIRONMENT }}-k8s-configuration
- name: Install helm charts
shell: bash
run: |
export TF_VAR_acr_username="${{ secrets.ACR_USERNAME }}"
export TF_VAR_acr_password="${{ secrets.ACR_PASSWORD }}"
export TF_VAR_acr_login_server_name="${{ secrets.ACR_LOGIN_SERVER_NAME }}"
export TF_VAR_gitops_tool="${{ github.event.inputs.GITOPS_TOOL }}"
terraform apply \
-var="acr_username=${TF_VAR_acr_username}" \
-var="acr_password=${TF_VAR_acr_password}" \
-var="acr_login_server_name=${TF_VAR_acr_login_server_name}" \
-var="gitops_tool=${TF_VAR_gitops_tool}" \
--auto-approve
run: terraform apply --auto-approve
continue-on-error: false
working-directory: ./terraform/envs/${{ github.event.inputs.ENVIRONMENT }}-k8s-configuration
env:
TF_VAR_acr_username: "${{ secrets.ACR_USERNAME }}"
TF_VAR_acr_password: "${{ secrets.ACR_PASSWORD }}"
TF_VAR_acr_login_server_name: "${{ secrets.ACR_LOGIN_SERVER_NAME }}"
TF_VAR_gitops_tool: "${{ github.event.inputs.GITOPS_TOOL }}"
if: ${{ github.event.inputs.INFRASTRUCTURE_OPERATIONS == 'helm-charts-install' || github.event.inputs.INFRASTRUCTURE_OPERATIONS == 'k8s-service-deploy' }}
- name: Uninstall helm charts
run: terraform destroy --auto-approve
Expand Down
7 changes: 6 additions & 1 deletion terraform/envs/sbx-k8s-configuration/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module "k8s" {
source = "../../modules/k8s"
environment = "sbx"
environment = var.environment
k8s_namespace = var.k8s_namespace
acr_login_server_name = var.acr_login_server_name
acr_username = var.acr_username
acr_password = var.acr_password
gitops_tool = var.gitops_tool
}
35 changes: 35 additions & 0 deletions terraform/envs/sbx-k8s-configuration/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
variable "environment" {
default = "sbx"
description = "The environment."
type = string
}

# K8s
variable "k8s_namespace" {
default = "gitops-ftw"
description = "K8s gitops-ftw namespace."
}

variable "acr_login_server_name" {
default = "TBD"
sensitive = true
description = "Sets an ACR registry server name."
}

variable "acr_username" {
default = "TBD"
sensitive = true
description = "Sets an ACR user name."
}

variable "acr_password" {
default = "TBD"
sensitive = true
description = "Sets an ACR password."
}

variable "gitops_tool" {
description = "String determining whether to install Argo CD or FluxCD. Viable options: [ argocd, fluxcd ]"
type = string
default = "argocd"
}
14 changes: 13 additions & 1 deletion terraform/envs/sbx-k8s-deployment/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
module "az" {
source = "../../modules/az"
environment = "sbx"
digital_product_affix = var.digital_product_affix
environment = var.environment
resource_instance_number = var.resource_instance_number
location = var.location
team = var.team
virtual_network_address_space = var.virtual_network_address_space
number_of_aks = var.number_of_aks
aks_admin_username = var.aks_admin_username
aks_enable_auto_scaling = var.aks_enable_auto_scaling
aks_node_count = var.aks_node_count
aks_max_node_count = var.aks_max_node_count
aks_vm_size = var.aks_vm_size
aks_os_disk_size_gb = var.aks_os_disk_size_gb
}

# module "aws" {
Expand Down

0 comments on commit 9d7c676

Please sign in to comment.