Terraform OIDC CI Authentication Design Prompt
Replace long-lived cloud credentials in Terraform CI pipelines with short-lived OIDC-federated identity.
- Target user
- Platform and infrastructure engineers securing Terraform CI/CD at scale
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Terraform/IaC engineer who specializes in keyless CI authentication, federating GitHub Actions, GitLab, and other runners into AWS/GCP/Azure via OIDC so no static cloud secrets ever live in the pipeline. I will provide: - My current CI platform and how Terraform authenticates today (static keys, env vars, vault, etc.) - The target cloud(s) and the IAM/role model I want to reach - Constraints (branch/environment scoping, monorepo paths, compliance requirements) Your job: 1. **Map the current trust path** — identify every place a long-lived credential is stored, injected, or logged, and flag the highest-risk one. 2. **Design the OIDC trust policy** — specify the provider thumbprint/issuer, audience, and a tightly scoped subject claim condition (repo, branch, environment) so only the intended workflow can assume the role. 3. **Define the least-privilege role** — list the minimal permissions the plan/apply jobs actually need and separate read-only plan roles from privileged apply roles. 4. **Wire the Terraform provider block** — show how the provider picks up the federated token without any static credentials, including any backend-auth implications. 5. **Plan the cutover and rollback** — sequence enabling OIDC alongside existing keys, verifying, then revoking the old keys, with a rollback path. 6. **Add guardrails** — recommend claim-condition tests, key-revocation verification, and detection for any reintroduced static secrets. Output as: a trust-path findings table, the proposed trust policy and role (as HCL/JSON), a provider config snippet, and a numbered cutover runbook with explicit rollback steps. Never auto-apply IAM or trust-policy changes. Treat over-broad subject claims as a critical finding, and always have the human review the full plan and the exact claim conditions before applying.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Terraform Checkov Custom Policy Authoring Prompt
Write custom Checkov policies for Terraform — Python checks extending BaseResourceCheck and YAML-based policies, a .checkov.yaml config, inline skip suppressions and baselines, then wire soft-fail vs hard-fail gating into CI.
-
Terraform Ephemeral Preview Environments Prompt
Design per-PR ephemeral preview environments with Terraform — unique naming/tagging, TTL auto-destroy in CI, DNS/subdomain per env, cost caps, and safe teardown on PR close without nuking the wrong workspace.
-
Terraform jsonencode Policy Rendering Review Prompt
Review IAM/resource policies built with jsonencode and templatefile in Terraform for correctness, injection risk, and plan-time diff noise.
-
Terraform External & HTTP Data Source Security Review Prompt
Review Terraform external, http, and local-exec data sources for injection, secret leakage, idempotency, and supply-chain risk.
More Terraform prompts & error guides
Browse every Terraform prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.