feat: org-wide S3-lister role, created by CI#33
Merged
Conversation
First IAM role created BY the CI (aws-github-oidc role) rather than by a human,
demonstrating the privilege-escalation-safe role-creation flow end to end.
- s3-lister-role/ root (terraform-aws-modules/iam): a read-only S3 lister
(AmazonS3ReadOnlyAccess) assumable by ANY principal in the AWS Organization
via an aws:PrincipalOrgID trust condition (no account IDs hardcoded).
- Honours the repo-wide contract: role sits under the managed path and carries
the tf-managed permissions boundary, so the CI grant permits its creation.
role_path is fed in CI from ${{ github.repository }}.
- .github/workflows/s3-lister-role.yml: Terraform GitOps — `plan` on PR, `apply`
on push to main, assuming the CI role via OIDC (no static AWS keys).
- Wire the new root into the lock-check matrix, mise `lock` task, and CLAUDE.md
(also adding aws-github-oidc, which was missing from the docs/lock list).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ision The s3-lister-role plan ran in the `default` workspace in CI, where the S3 backend ignores workspace_key_prefix — so its key resolved to `terraform.tfstate` and collided with terraform-state-bucket's state (the plan wanted to destroy the bucket's versioning!). The `infrastructure` workspace only existed locally via a gitignored .terraform/environment, invisible to CI. Make workspace selection declarative and version-controlled: - .github/actions/terraform: a reusable composite action that, for a root, loops over workspace/<name>.tfvars files — filename = terraform workspace name, contents = that workspace's variables — running `workspace select -or-create` + plan/apply -var-file per workspace. - s3-lister-role/workspace/infrastructure.tfvars: declares the `infrastructure` workspace and its vars (region, role_name, role_path, permissions_boundary_arn, org_id). State now lands at s3-lister-role/infrastructure/terraform.tfstate. - s3-lister-role.yml: use the composite action instead of bare init/plan/apply; drop the TF_VAR_role_path env (now in the tfvars). - Document the workspaces convention in CLAUDE.md. Verified locally: with the workspace selected, `plan` is `2 to add, 0 to change, 0 to destroy` (only the role) — no more cross-root state collision. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nbrieussel
commented
Jun 13, 2026
Drop the multi-workspace loop, nullglob array, group logging and verbose guard — one workspace/<name>.tfvars per root is the real case. Derive the workspace from the single file and plan/apply with its var-file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The point of this PR is to watch the CI role create the role via OIDC, so run `apply` on every trigger instead of plan-on-PR / apply-on-main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nbrieussel
marked this pull request as ready for review
June 15, 2026 13:44
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.
Context
First IAM role created by the CI (the
aws-github-oidcrole from #32) instead of by a human — exercising the privilege-escalation-safe role-creation flow end to end. Triggered from the remote:applyon push to main.What it creates
s3-lister-role/— a read-only S3 lister (AmazonS3ReadOnlyAccess, same access the original GitHub Action had), assumable by anyone in the AWS Organization:No account IDs hardcoded — the
aws:PrincipalOrgIDcondition admits every (and only) caller whose creds belong to orgo-f9lb1e5es9.Honours the boundary contract
The role sits under the managed
pathand carries thepermissions_boundary— the two conditions the CI grant requires, or the apply is denied.role_pathis fed in CI from${{ github.repository }}.GitOps workflow
.github/workflows/s3-lister-role.ymlassumes the CI role via OIDC (no static keys) and:terraform plan(this PR will show the role to be created)terraform applyAlso
Wired
s3-lister-roleinto the lock-check matrix, the miselocktask, and CLAUDE.md — and addedaws-github-oidc, which was missing from the docs/lock list.How to assume it (once applied)
aws sts assume-role \ --role-arn "$(terraform -chdir=s3-lister-role output -raw role_arn)" \ --role-session-name demo🤖 Generated with Claude Code