[POC] Manual plan approval for account customizations pipelines
This is a working reference implementation, shared for feedback.
Summary
I run AFT in production and needed what #153 #481 #541 have been asking for for years, a human review between terraform plan and terraform apply in the per-account customizations pipelines. This PoC was built on a fork of AFT 1.21.1 using only native CodePipeline features, and have been testing it running it across our small account fleet.
We know this project does not currently accept community contributions, so this is deliberately not a PR. We're sharing the design as a concrete starting point, hoping it helps the maintainers shape and prioritize an official feature
This also gives the community something specific to give feedback on.
EDIT: After publishing this, I've found Igor's proposal: #542 linking for visibility. As I missed it for 1y.
What the reference implementation does
- Each customizations stage is split in two:
Plan (runs terraform plan -out=tfplan,
publishes the plan as a pipeline artifact) and Approve + Apply (native Manual
Approval action, then terraform apply tfplan on the reviewed artifact).
- No changes requires no approval: a CodePipeline V2
before_entry rule skips the
Approve+Apply stage entirely when the plan is empty.
- The approval dialog shows the account name/id and links to the plan's build logs;
notifications go to an SNS topic. The timeout is configurable (default 5 minutes).
- Backward compatible during rollout: the shared buildspecs branch on a
TF_COMMAND
env var injected by the pipeline (plan / apply / unset = upstream behavior verbatim), so
pipelines that haven't been re-provisioned with the new stage layout keep working
unchanged.
How to use it
- Update your root TF invokation.
module "aft" {
source = "github.com/v-rosa/terraform-aws-control_tower_account_factory?ref=approval-stage-poc"
....
# these 2 properties are really needed in order to allow the pipeline customization SFN to work as expected.
aft_framework_repo_url = "https://github.com/v-rosa/terraform-aws-control_tower_account_factory.git"
aft_framework_repo_git_ref = "approval-stage-poc"
aft_customizations_approval_timeout_in_minutes = 6
}
- For existing pipelines, select a sandbox account, and update the customization pipeline by running the SFN
aft-invoke-customizations with the payload:
{
"include": [
{
"type": "accounts",
"target_value": [
"<account-id>"
]
}
]
}
- Wait until the execution finished. After this your customization pipeline will automatically trigger and look like:
The approval modal:
- And if you want you can play with the approval notification topic (
aft_approvals_sns_topic_arn) and publish your cool approvals.
Deliberate opinions (where feedback would be most valuable)
This is intentionally opinionated; an official feature might choose differently:
- Short (5-minute) approval expiry, but configurable.
- Skip-on-no-changes is automatic and non-overridable. the console also renders the engaged SKIP rule in red ("expected true but got false"), which is cosmetic but confusing at first sight.
- Reviewers read the plan in the CodeBuild logs (deep link in the approval dialog)
Known gaps
- I've left approval-group management out of scope. (IDK if this is really a gap compared with the current status).
- Not tested with Terraform Cloud/Enterprise workspaces. I run the OSS distribution;
- I've tested only with single pipeline run, no bulk rollout of changes for many accounts. This is not our use case, some edge cases might appear ofc.
Availability & maintenance
The full diff against the 1.21.1 release is available here: v-rosa#1. It is shared as-is: I can't promise to keep the fork up-to-date with future AFT releases, so please treat it as a design artifact and conversation starter.
Have a safe deployment!
[POC] Manual plan approval for account customizations pipelines
This is a working reference implementation, shared for feedback.
Summary
I run AFT in production and needed what #153 #481 #541 have been asking for for years, a human review between
terraform planandterraform applyin the per-account customizations pipelines. This PoC was built on a fork of AFT 1.21.1 using only native CodePipeline features, and have been testing it running it across our small account fleet.We know this project does not currently accept community contributions, so this is deliberately not a PR. We're sharing the design as a concrete starting point, hoping it helps the maintainers shape and prioritize an official feature
This also gives the community something specific to give feedback on.
EDIT: After publishing this, I've found Igor's proposal: #542 linking for visibility. As I missed it for 1y.
What the reference implementation does
Plan(runsterraform plan -out=tfplan,publishes the plan as a pipeline artifact) and
Approve + Apply(native ManualApproval action, then
terraform apply tfplanon the reviewed artifact).before_entryrule skips theApprove+Applystage entirely when the plan is empty.notifications go to an SNS topic. The timeout is configurable (default 5 minutes).
TF_COMMANDenv var injected by the pipeline (plan / apply / unset = upstream behavior verbatim), so
pipelines that haven't been re-provisioned with the new stage layout keep working
unchanged.
How to use it
aft-invoke-customizationswith the payload:{ "include": [ { "type": "accounts", "target_value": [ "<account-id>" ] } ] }The approval modal:
aft_approvals_sns_topic_arn) and publish your cool approvals.Deliberate opinions (where feedback would be most valuable)
This is intentionally opinionated; an official feature might choose differently:
Known gaps
Availability & maintenance
The full diff against the 1.21.1 release is available here: v-rosa#1. It is shared as-is: I can't promise to keep the fork up-to-date with future AFT releases, so please treat it as a design artifact and conversation starter.
Have a safe deployment!