Skip to content

No-keys CI/CD kit.

Stop pasting static AWS access keys and GCP service-account JSON files into GitHub Secrets. Put the deploy gate in the cloud trust policy instead.

Why this setup

  • Zero long-lived keys: GitHub mints a short-lived OIDC token per job, exchanged directly with AWS STS or GCP Workload Identity Federation.
  • Gate enforced by the cloud: on AWS, the prod role trusts only tokens from environment:prod. Even if someone edits the workflow YAML on a branch, AWS refuses the token without a human reviewer approving the environment.
  • Split plan from apply: on GCP, pull requests can only impersonate the read-only plan account. Only refs/heads/main can touch apply.

Creates the GitHub OIDC provider and two roles. The prod trust policy requires the GitHub "prod" environment, so the approval gate lives in AWS IAM, not only in YAML.

variable "github_repo" {
  type        = string
  description = "GitHub repo in owner/name format"
}

resource "aws_iam_openid_connect_provider" "github" {
  url             = "https://token.actions.githubusercontent.com"
  client_id_list  = ["sts.amazonaws.com"]
  thumbprint_list = ["6938fd4d98bab03faadb97b34396831e3780aea1"]
}

data "aws_iam_policy_document" "github_prod_assume" {
  statement {
    effect  = "Allow"
    actions = ["sts:AssumeRoleWithWebIdentity"]
    principals {
      type        = "Federated"
      identifiers = [aws_iam_openid_connect_provider.github.arn]
    }
    condition {
      test     = "StringEquals"
      variable = "token.actions.githubusercontent.com:aud"
      values   = ["sts.amazonaws.com"]
    }
    condition {
      test     = "StringEquals"
      variable = "token.actions.githubusercontent.com:sub"
      values   = ["repo:${var.github_repo}:environment:prod"]
    }
  }
}

resource "aws_iam_role" "github_prod" {
  name               = "github-actions-prod"
  assume_role_policy = data.aws_iam_policy_document.github_prod_assume.json
}

Free zip bundleZIP, 3 KB

Download the full AWS + GCP No-Keys CI/CD Kit

Complete Terraform roots for AWS OIDC and GCP Workload Identity Federation, both GitHub Actions workflows, and a short README.

  • aws/oidc.tf + aws/deploy.yml (separate CI and reviewer-gated prod roles)
  • gcp/wif.tf + gcp/terraform.yml (read-only plan SA on PRs, main-only apply SA)
  • README.md with exact GitHub repo variable names

One email each Sunday, unsubscribe in one click. Or skip the box: the file is right here. Hit a trust-policy error? Reply to the email and I will help you debug it for free.

Still have static keys and manual deploys?

Send me your current deploy setup or Terraform layout. I do five free 10-minute Loom teardowns a month showing the safest order to lock it down without downtime.

Just your email. Nothing to write upfront. Or book a 20-minute call.

One email each Sunday.

The new video and the real numbers behind it.

Or talk to me.

App, cloud, or both. Twenty minutes.