Authenticate the Terraform workflows with OIDC - #188
Merged
Conversation
|
Terraform plan in terraform No changes. Your infrastructure matches the configuration.✅ Plan applied in Apply Terraform changes on merge #43 |
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.
Part of #182. Deliberately not a closing reference — the last action item on that issue is retiring the static credentials, and that only happens once the runs below are confirmed green. The issue stays open after this merges.
Both Terraform workflows now assume a role through GitHub's OIDC provider instead of passing a long-lived access key and secret.
terraform-plan.yamldevops-security-tf-planrefs/heads/*and:pull_requestReadOnlyAccessterraform-apply.yamldevops-security-tf-applyrefs/heads/mainonlyAdministratorAccessThe branch scoping on the apply role is the security win beyond retiring the keys: a branch or a pull request cannot assume it at all, which is something a static key has no equivalent for.
Both roles already exist. They were created by hand in
035866691871on 2026-09-05, before this pull request, and are taggedmanaged-by=exempt. Creating them by hand is deliberate — it dissolves the bootstrap problem where the Terraform that creates the role is run by the workflow that needs the role to authenticate.terraform/aws-gha-oidc-providers.tfnow carries a note saying so, because a reader seeing incubator's roles declared and this repo's absent would otherwise "fix" it and reintroduce the circularity.The plan role is
ReadOnlyAccessalone, with no backend policy. The issue predicted it would needdynamodb:PutItem/DeleteItemfor state locking. It does not:dflook/terraform-planadds-lock=falseunconditionally, so a plan never touches the lock table. The other three candidates were checked too — the state bucket isAES256with no customer KMS key, its bucket policy is a TLS-enforcement deny with no principal restriction, and this configuration has no data sources needing more thanReadOnlyAccess. That also explains whyincubator-tf-planhas run onReadOnlyAccessall along; it was never missing a permission.Why there is a Terraform change in a workflow pull request. Both workflows filter on
paths: ['**/*.tf'], so a pull request touching only workflow files triggers neither, and the switch would sit unexercised until somebody else's Terraform change landed. The note inaws-gha-oidc-providers.tfis itself a.tfchange, so it makes the plan run here and the apply run on merge. No artificial no-op was needed.Checked locally before pushing:
terraform validatepasses on 1.16.0, the version this repo pins.terraform fmt -checkreportsaws-groups.tfandimports.tf, both of which are untouched by this pull request and already unformatted onmain— left alone rather than swept into this change.Deliberately out of scope:
AKIAQQWOSJEPUH74UTOJis still active and both repository secrets are still set. That is the rollback path and it stays until both runs are green.aws-actions/configure-aws-credentialsstays at v4. Bump configure-aws-credentials to v6 and dflook/terraform-* to v3 in the Terraform workflows #170 bumps it to v6 and rewrites this same step; whichever merges second will need a rebase.To roll back: revert this pull request. The static key still works, so CI recovers immediately.