Repository navigation
ci: gate production terragrunt applies behind service releases - #1105
Merged
Merged
Conversation
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Changes under aws/<service>/ outside an environment directory (modules, root.hcl, CHANGELOG.md) matched no stack, so they received no deploy label. A terragrunt-shared stack now labels the service, and its target is excluded from every deploy job so it only triggers detection. The label dispatcher skips release-please PRs so their CHANGELOG.md updates do not plan every environment. Signed-off-by: panicboat <panicboat@gmail.com>
Release tags and release-please branches name a service, and the services to release come from the apply_trigger: release environments in workflow-config. The executor gains optional ref and github-environment inputs so a release run can check out a tag and gate on an environment. Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Add tests that read auto-label--deploy-trigger.yaml for the merge-only apply expression and the terragrunt-shared matrix excludes. Serialize auto-release plan runs per release branch and apply runs per working directory, and limit the resolve jobs to contents: read. Print the rejected release tag or branch on a single line so a crafted value cannot inject workflow commands. Document shared-file detection and the release-please config requirement. Signed-off-by: panicboat <panicboat@gmail.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Contributor
❌ Plan Failed (eks-secrets/production)
Change Result (Click me)Changes to Outputs:
+ pod_identity_role_arn = (known after apply)
+ pod_identity_role_name = "eks-production-eso" |
Contributor
❌ Plan Failed (eks-holmesgpt/production)
Change Result (Click me)Changes to Outputs:
+ pod_identity_role_arn = (known after apply)
+ pod_identity_role_name = "eks-production-holmesgpt"
Error: reading EKS Cluster (eks-production): couldn't find resource
with module.eks.data.aws_eks_cluster.this,
on ../../eks/lookup/main.tf line 1, in data "aws_eks_cluster" "this":
1: data "aws_eks_cluster" "this" {
|
Contributor
❌ Plan Failed (eks-karpenter/production)
|
Contributor
Plan Result (github-oidc-auth/master) |
Contributor
❌ Plan Failed (eks-traces/production)
Change Result (Click me)Changes to Outputs:
+ bucket_name = (known after apply)
+ bucket_path_prefix = "production"
+ pod_identity_role_arn = (known after apply)
+ pod_identity_role_name = "eks-production-tempo"
Error: reading EKS Cluster (eks-production): couldn't find resource
with module.eks.data.aws_eks_cluster.this,
on ../../eks/lookup/main.tf line 1, in data "aws_eks_cluster" "this":
1: data "aws_eks_cluster" "this" {
|
Contributor
Plan Result (github-oidc-auth/develop)
|
Signed-off-by: panicboat <panicboat@gmail.com>
3 of 7 tasks
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Signed-off-by: panicboat <panicboat@gmail.com>
Contributor
✅ Apply Succeeded (github-oidc-auth/develop)Details (Click me)Oct 24 13:26:21.506 INF download and unarchive the package program=aqua version=2.64.0 env=linux/amd64 exe_name=terragrunt package_name=gruntwork-io/terragrunt package_version=v1.0.2 registry=standard
Initializing the backend...
Successfully configured the backend "s3"! OpenTofu will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins...
- Finding hashicorp/aws versions matching "6.68.0"...
- Finding hashicorp/tls versions matching "~> 4.4"...
- Installing hashicorp/tls v4.4.2 to the shared cache directory...
- Installing hashicorp/aws v6.68.0 to the shared cache directory...
- Installed hashicorp/tls v4.4.2 (signed, key ID 0C0AF313E5FD9F80)
- Using hashicorp/tls v4.4.2 from the shared cache directory
- Installed hashicorp/aws v6.68.0 (signed, key ID 0C0AF313E5FD9F80)
- Using hashicorp/aws v6.68.0 from the shared cache directory
Providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://opentofu.org/docs/cli/plugins/signing/
OpenTofu has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that OpenTofu can guarantee to make the same selections by default when
you run "tofu init" in the future.
OpenTofu has been successfully initialized!
You may now begin working with OpenTofu. Try running "tofu plan" to see
any changes that are required for your infrastructure. All OpenTofu commands
should now work.
If you ever set or change modules or backend configuration for OpenTofu,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
data.tls_certificate.github: Reading...
data.tls_certificate.github: Read complete after 0s [id=6bcf7b7f2005c947073a003ff3b596f7fcc8066f]
data.aws_caller_identity.current: Reading...
aws_iam_openid_connect_provider.github[0]: Refreshing state... [id=arn:aws:iam::270242382571:oidc-provider/token.actions.githubusercontent.com]
aws_cloudwatch_log_group.github_actions_logs: Refreshing state... [id=/github-actions/github-oidc-auth-develop]
data.aws_caller_identity.current: Read complete after 0s [id=270242382571]
aws_iam_policy.terragrunt_state_lock: Refreshing state... [id=arn:aws:iam::270242382571:policy/github-oidc-auth-develop-terragrunt-state-lock]
aws_iam_role.apply: Refreshing state... [id=github-oidc-auth-develop-github-actions-apply-role]
aws_iam_role.plan: Refreshing state... [id=github-oidc-auth-develop-github-actions-plan-role]
aws_iam_role_policy_attachment.apply_administrator_access: Refreshing state... [id=github-oidc-auth-develop-github-actions-apply-role/arn:aws:iam::aws:policy/AdministratorAccess]
aws_iam_role_policy_attachment.plan_read_only: Refreshing state... [id=github-oidc-auth-develop-github-actions-plan-role/arn:aws:iam::aws:policy/ReadOnlyAccess]
aws_iam_role_policy_attachment.plan_state_lock: Refreshing state... [id=github-oidc-auth-develop-github-actions-plan-role/arn:aws:iam::270242382571:policy/github-oidc-auth-develop-terragrunt-state-lock]
OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
- destroy
OpenTofu will perform the following actions:
# aws_cloudwatch_log_group.github_actions_logs will be destroyed
# (because aws_cloudwatch_log_group.github_actions_logs is not in configuration)
- resource "aws_cloudwatch_log_group" "github_actions_logs" {
- arn = "arn:aws:logs:us-east-1:270242382571:log-group:/github-actions/github-oidc-auth-develop" -> null
- deletion_protection_enabled = false -> null
- id = "/github-actions/github-oidc-auth-develop" -> null
- log_group_class = "STANDARD" -> null
- name = "/github-actions/github-oidc-auth-develop" -> null
- region = "us-east-1" -> null
- retention_in_days = 7 -> null
- skip_destroy = false -> null
- tags = {
- "Component" = "github-oidc-auth"
- "Environment" = "develop"
- "LogGroup" = "github-oidc-auth-develop-github-actions"
- "ManagedBy" = "terraform"
- "Owner" = "panicboat"
- "Project" = "github-oidc-auth"
- "Repository" = "panicboat/platform"
} -> null
- tags_all = {
- "Component" = "github-oidc-auth"
- "Environment" = "develop"
- "LogGroup" = "github-oidc-auth-develop-github-actions"
- "ManagedBy" = "terraform"
- "Owner" = "panicboat"
- "Project" = "github-oidc-auth"
- "Repository" = "panicboat/platform"
} -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
Changes to Outputs:
- cloudwatch_log_group_arn = "arn:aws:logs:us-east-1:270242382571:log-group:/github-actions/github-oidc-auth-develop" -> null
- cloudwatch_log_group_name = "/github-actions/github-oidc-auth-develop" -> null
aws_cloudwatch_log_group.github_actions_logs: Destroying... [id=/github-actions/github-oidc-auth-develop]
aws_cloudwatch_log_group.github_actions_logs: Destruction complete after 1s
Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
Outputs:
allowed_environments = tolist([
"develop",
])
apply_role_arn = "arn:aws:iam::270242382571:role/github-oidc-auth-develop-github-actions-apply-role"
apply_role_name = "github-oidc-auth-develop-github-actions-apply-role"
github_org = "panicboat"
github_repos = tolist([
"monorepo",
"platform",
])
oidc_provider_arn = "arn:aws:iam::270242382571:oidc-provider/token.actions.githubusercontent.com"
oidc_provider_url = "https://token.actions.githubusercontent.com"
plan_role_arn = "arn:aws:iam::270242382571:role/github-oidc-auth-develop-github-actions-plan-role"
plan_role_name = "github-oidc-auth-develop-github-actions-plan-role"
|
Contributor
✅ Apply Succeeded (github-oidc-auth/master)Details (Click me)Oct 24 13:26:22.061 INF download and unarchive the package program=aqua version=2.64.0 env=linux/amd64 exe_name=terragrunt package_name=gruntwork-io/terragrunt package_version=v1.0.2 registry=standard
Initializing the backend...
Successfully configured the backend "s3"! OpenTofu will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins...
- Finding hashicorp/tls versions matching "~> 4.4"...
- Finding hashicorp/aws versions matching "6.68.0"...
- Installing hashicorp/tls v4.4.2 to the shared cache directory...
- Installing hashicorp/aws v6.68.0 to the shared cache directory...
- Installed hashicorp/tls v4.4.2 (signed, key ID 0C0AF313E5FD9F80)
- Using hashicorp/tls v4.4.2 from the shared cache directory
- Installed hashicorp/aws v6.68.0 (signed, key ID 0C0AF313E5FD9F80)
- Using hashicorp/aws v6.68.0 from the shared cache directory
Providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://opentofu.org/docs/cli/plugins/signing/
OpenTofu has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that OpenTofu can guarantee to make the same selections by default when
you run "tofu init" in the future.
OpenTofu has been successfully initialized!
You may now begin working with OpenTofu. Try running "tofu plan" to see
any changes that are required for your infrastructure. All OpenTofu commands
should now work.
If you ever set or change modules or backend configuration for OpenTofu,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Acquiring state lock. This may take a few moments...
data.tls_certificate.github: Reading...
data.tls_certificate.github: Read complete after 0s [id=6bcf7b7f2005c947073a003ff3b596f7fcc8066f]
data.aws_caller_identity.current: Reading...
aws_iam_openid_connect_provider.github[0]: Refreshing state... [id=arn:aws:iam::559744160976:oidc-provider/token.actions.githubusercontent.com]
data.aws_caller_identity.current: Read complete after 0s [id=559744160976]
aws_iam_policy.terragrunt_state_lock: Refreshing state... [id=arn:aws:iam::559744160976:policy/github-oidc-auth-master-terragrunt-state-lock]
aws_iam_role.plan: Refreshing state... [id=github-oidc-auth-master-github-actions-plan-role]
aws_iam_role.apply: Refreshing state... [id=github-oidc-auth-master-github-actions-apply-role]
aws_iam_role.bedrock[0]: Refreshing state... [id=github-oidc-auth-master-github-actions-bedrock-role]
aws_iam_role_policy_attachment.plan_read_only: Refreshing state... [id=github-oidc-auth-master-github-actions-plan-role/arn:aws:iam::aws:policy/ReadOnlyAccess]
aws_iam_role_policy_attachment.plan_state_lock: Refreshing state... [id=github-oidc-auth-master-github-actions-plan-role/arn:aws:iam::559744160976:policy/github-oidc-auth-master-terragrunt-state-lock]
aws_iam_role_policy_attachment.apply_administrator_access: Refreshing state... [id=github-oidc-auth-master-github-actions-apply-role/arn:aws:iam::aws:policy/AdministratorAccess]
aws_iam_role_policy.bedrock_invoke[0]: Refreshing state... [id=github-oidc-auth-master-github-actions-bedrock-role:bedrock-invoke]
No changes. Your infrastructure matches the configuration.
OpenTofu has compared your real infrastructure against your configuration and
found no differences, so no changes are needed.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
allowed_environments = tolist([
"master",
])
apply_role_arn = "arn:aws:iam::559744160976:role/github-oidc-auth-master-github-actions-apply-role"
apply_role_name = "github-oidc-auth-master-github-actions-apply-role"
bedrock_role_arn = "arn:aws:iam::559744160976:role/github-oidc-auth-master-github-actions-bedrock-role"
github_org = "panicboat"
github_repos = tolist([
"monorepo",
"platform",
])
oidc_provider_arn = "arn:aws:iam::559744160976:oidc-provider/token.actions.githubusercontent.com"
oidc_provider_url = "https://token.actions.githubusercontent.com"
plan_role_arn = "arn:aws:iam::559744160976:role/github-oidc-auth-master-github-actions-plan-role"
plan_role_name = "github-oidc-auth-master-github-actions-plan-role"
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
module を修正すると、その module を参照する全環境に同じ main merge で apply される。
そのため develop で確かめてから production に出す段階を踏めない。
production 以外は今までどおり main merge で apply し、production はサービスごとの release PR の merge(release 公開)で apply する形にする。
docs/superpowers/specs/2026-10-24-terragrunt-production-release-design.mddocs/superpowers/plans/2026-10-24-terragrunt-production-release.mdWhat
workflow-config.yamlの各環境にapply_triggerを持たせる。masterとdevelopはmerge、productionはreleaseにする。aws_regionは、state bucket の region に合わせてap-northeast-1にした(aws/github-oidc-auth/develop/env.hclのus-east-1には合わせていない)。apply_trigger == 'merge'の target だけに apply を割り当てる。terragrunt-sharedstack(aws/{service})を追加し、modules/やroot.hclの変更でもdeploy:<service>が付くようにする。release-please--)ではラベル付与を走らせない。aws/<service>/release-please-config.jsonごとに動かす(monorepo と同じ方式)。choreとrefactorも CHANGELOG に出してリリース対象にする。apply_trigger: mergeの環境ディレクトリだけを変える commit はexclude-pathsで release から外す。modules/やroot.hclは環境どうしで共有しているので除外しない。auto-release--plan.yamlで release PR に production の plan を出す。auto-release--trigger.yamlで release 公開時に production を apply する。workflow_dispatchに tag を渡す。productionを宣言する。apply role の trust がmainとenvironment:productionしか許可していないため。excludeにenvironment: productionを置く。release-targets.shも production を target にしないので、platform からは production を plan も apply もしない。excludeを外す。scripts/terragrunt-release/に置き、test-terragrunt-release.yamlで CI 実行する。Merge 前に確認すること
aws/<service>/に設定ファイルを追加するので、12 サービスにdeploy:<service>が自動で付く。masterとdevelopの stack(github-oidc-authなど)が apply される。aws/の module 変更は apply されていなかった。master(cost-managementなど)に未 apply の差分があれば、この PR の plan に出る。Test plan
bash scripts/terragrunt-release/test.shが 33 件すべて PASSvalidate-apply-trigger.shとcheck-release-configs.shが exit 0actionlintは既存のtarget-environmentエラー 1 件のみaws iam get-roleで確認master/developの存在する環境だけ plan が走り、production の plan が出ないgithub-environmentが空)で動くplanjob が、release 公開ではapplyjob が、target が空なので skip されるexcludeを外した後)release PR に production の plan が出て、merge で production だけが apply される。--ref <tag>のworkflow_dispatchで再実行できるaws/github-oidc-auth/develop/だけを変える PR の merge で、github-oidc-authの release PR ができないdeploy-kubernetesがterragrunt-sharedの target を実行しない🤖 Generated with Claude Code
https://claude.ai/code/session_01BZfNTtmPjmrDmh1MAMtiFS