Skip to content

Refactor Terraform configuration to use variables instead of local configurations#1

Merged
jesbinjoseph merged 25 commits into
developfrom
DVOPS-48-implement-tfvars-with-secrets-manager
May 19, 2026
Merged

Refactor Terraform configuration to use variables instead of local configurations#1
jesbinjoseph merged 25 commits into
developfrom
DVOPS-48-implement-tfvars-with-secrets-manager

Conversation

@jesbinjoseph

Copy link
Copy Markdown
Contributor
  • Updated GKE cluster module to use var.zone and var.node_pools instead of local configurations.
  • Modified jumphost resources to reference var.app, var.environment, and var.service_account_email.
  • Replaced local configurations with variables in locals.tf for common labels and required tags.
  • Adjusted network module to utilize var.gke_subnets, var.gke_pods_range, and var.gke_services_range.
  • Changed output values to use variables for database connection strings and names.
  • Enhanced Makefile to include new targets for pulling and pushing tfvars from GCP Secret Manager.
  • Updated Cloud DNS module to utilize variables for naming and domain configuration.
  • Removed deprecated config.tf file and adjusted enable-apis.tf to use variables.
  • Deleted unused backup and bootstrap scripts, and added new scripts for managing tfvars in Secret Manager.
  • Expanded variables.tf to include additional configuration options and defaults.

…nfigurations

- Updated GKE cluster module to use `var.zone` and `var.node_pools` instead of local configurations.
- Modified jumphost resources to reference `var.app`, `var.environment`, and `var.service_account_email`.
- Replaced local configurations with variables in locals.tf for common labels and required tags.
- Adjusted network module to utilize `var.gke_subnets`, `var.gke_pods_range`, and `var.gke_services_range`.
- Changed output values to use variables for database connection strings and names.
- Enhanced Makefile to include new targets for pulling and pushing tfvars from GCP Secret Manager.
- Updated Cloud DNS module to utilize variables for naming and domain configuration.
- Removed deprecated config.tf file and adjusted enable-apis.tf to use variables.
- Deleted unused backup and bootstrap scripts, and added new scripts for managing tfvars in Secret Manager.
- Expanded variables.tf to include additional configuration options and defaults.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the OpenTofu/Terraform configuration to consume environment configuration via var.* from tfvars files (stored in GCP Secret Manager) instead of decoding a single JSON “config” secret into local.cfg.

Changes:

  • Replaces local.cfg[...] usages across modules with explicit variables in variables.tf, and updates resources/modules to reference var.*.
  • Introduces tfvars Secret Manager workflows (scripts/tfvars-pull.sh, scripts/tfvars-push.sh) and updates module Makefiles to pull/push and pass -var-file.
  • Updates environment documentation/templates to tfvars (environments/sample.tfvars) and removes the legacy JSON/config tooling (config.tf, JSON samples, bootstrap/edit/view scripts).

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
variables.tf Expands the shared input variable contract to replace prior local.cfg config decoding.
scripts/tfvars-push.sh Adds helper to push tfvars into Secret Manager and verify upload via hash.
scripts/tfvars-pull.sh Adds helper to pull tfvars from Secret Manager to a local file for module runs.
scripts/config-view.sh Removes legacy JSON config viewing script (no longer used with tfvars model).
scripts/config-edit.sh Removes legacy JSON config editing script (no longer used with tfvars model).
scripts/bootstrap.sh Removes legacy JSON secret bootstrap script (replaced by tfvars push workflow).
scripts/backup-k8s-resources.sh Removes unused k8s backup helper script.
README.md Adds repo-level documentation reflecting the tfvars + Secret Manager workflow.
pre-infra/Makefile Adds pull/push tfvars targets and runs plan/apply/destroy with -var-file.
pre-infra/enable-apis.tf Switches conditional API enablement to variable flags (and drops some prior conditionals).
pre-infra/cloud-dns.tf Updates Cloud DNS naming/config to use var.*.
KMS/Makefile Adds pull/push tfvars targets and runs plan/apply/destroy with -var-file.
KMS/kms.tf Updates KMS keyring naming and owners to use var.*.
infra/outputs.tf Updates DB-related outputs to use var.* naming components.
infra/network.tf Updates network CIDR inputs to use var.* instead of decoded config.
infra/Makefile Adds pull/push tfvars targets and runs plan/apply/destroy with -var-file.
infra/locals.tf Rebuilds derived names/labels/tags from var.* and override variables.
infra/jumphost.tf Updates jumphost naming/zone/SSH keys/service account to use var.*.
infra/gke.tf Updates cluster zone and node pool configuration to use var.*.
infra/github-wif.tf Updates GitHub WIF gating/config to use variables rather than decoded config.
infra/gcs.tf Updates bucket/service-account/KMS IAM wiring to use var.* naming + project number input.
infra/cloudarmour.tf Updates Cloud Armor enablement and naming to use var.*.
infra/cloud-sql.tf Updates Cloud SQL naming/sizing/zone inputs to use var.*.
infra/billing-budget.tf Removes billing budget resources (previously config-gated).
environments/sample.tfvars Adds canonical sanitized tfvars template for environments.
environments/sample.json Removes legacy JSON sample payload.
environments/README.md Updates environment docs to tfvars usage and variable reference.
deploy/secrets.tf Switches DICOM secret gating to var.enable_dicom.
deploy/Makefile Adds pull/push tfvars targets and runs plan/apply/destroy with -var-file.
deploy/locals.tf Rebuilds deploy locals from var.* (names, domains, secrets/config map merges).
deploy/legacy-ingress.tf Switches legacy ingress domain iteration to use var.*.
deploy/helm.tf Switches DICOM Helm release gating to var.enable_dicom.
deploy/helm-values.tf Switches Helm image/domain inputs to var.* instead of decoded config.
config.tf Removes the JSON Secret Manager decode-based config mechanism (local.cfg).
AGENTS.md Adds contributor/operator guidelines for module ordering and tfvars workflow.
.github/instructions/terraform.instructions.md Adds Terraform/OpenTofu contribution conventions aligned to the new tfvars model.
.github/instructions/helm.instructions.md Adds Helm chart conventions and Terraform value-injection guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread variables.tf
Comment thread variables.tf
Comment on lines +6 to 10
variable "project_number" {
description = "GCP project number"
type = string
default = null
}
Comment thread variables.tf
Comment thread variables.tf
Comment thread deploy/helm-values.tf
Comment thread scripts/tfvars-pull.sh Outdated
Comment thread infra/github-wif.tf Outdated
Comment thread AGENTS.md Outdated
Comment thread pre-infra/enable-apis.tf
Comment thread .github/instructions/terraform.instructions.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

.github/workflows/helm-lint-test.yml:1

  • Removing ct.yaml together with .github/workflows/helm-lint-test.yml eliminates all automated lint/template coverage for the Helm charts under helm_charts/. If this is intentional (e.g. CI is being moved elsewhere), please note it in the PR description; otherwise consider keeping the workflow so chart regressions are still caught on PRs.

Comment thread infra/gke.tf
Comment thread infra/github-wif.tf Outdated
Comment thread deploy/helm-values.tf Outdated
Comment thread variables.tf
Comment thread scripts/tfvars-push.sh Outdated
Comment thread infra/Makefile
@jesbinjoseph jesbinjoseph merged commit a066cc8 into develop May 19, 2026
@jesbinjoseph jesbinjoseph deleted the DVOPS-48-implement-tfvars-with-secrets-manager branch May 19, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants