Skip to content

fix(terraform): resolve account_id from AWS_ACCOUNT_ID env#31

Merged
stxkxs merged 1 commit into
mainfrom
env-account-id-from-getenv
Jun 7, 2026
Merged

fix(terraform): resolve account_id from AWS_ACCOUNT_ID env#31
stxkxs merged 1 commit into
mainfrom
env-account-id-from-getenv

Conversation

@stxkxs

@stxkxs stxkxs commented Jun 7, 2026

Copy link
Copy Markdown
Member

The per-environment env.hcl files set account_id, which root.hcl embeds in the remote-state bucket name (eks-agent-platform-tfstate-<account_id>-<region>). terragrunt evaluates that at parse time, before any AWS API is reachable, so the value can't arrive as a TF_VAR_ (those reach the leaf, not the backend config).

It now resolves from the AWS_ACCOUNT_ID environment variable via get_env, so no AWS account id lives in git — this is a public repo. The orchestrator (portal's per-environment workspace) sets AWS_ACCOUNT_ID; a manual leaf run exports it in the shell, the same way the other identifiers arrive as TF_VAR_*. Applied across dev, staging, and production for a uniform pattern (production previously carried a real id; dev/staging were REPLACE_WITH_* placeholders).

Validated: terragrunt hcl format --check clean on all three; terragrunt render parses the config and builds the bucket name from AWS_ACCOUNT_ID (fails only later at the AWS-credential stage, confirming get_env resolves at parse time).

The per-environment env.hcl files set account_id, which root.hcl embeds in the
remote-state bucket name (eks-agent-platform-tfstate-<account_id>-<region>).
terragrunt evaluates that at parse time, before any AWS API is reachable, so the
value can't arrive as a TF_VAR_ (those reach the leaf module, not the backend
config). It now resolves from the AWS_ACCOUNT_ID environment variable via
get_env, so no AWS account id lives in git — this is a public repo. The
orchestrator (portal's per-environment workspace) sets AWS_ACCOUNT_ID; a manual
leaf run exports it in the shell, the same way the other identifiers arrive as
TF_VAR_*. Applied across dev, staging, and production for a uniform pattern.
@stxkxs stxkxs merged commit b82e378 into main Jun 7, 2026
15 checks passed
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.

1 participant