Skip to content

Instantly share code, notes, and snippets.

@BernhardRode
Last active August 12, 2025 14:45
Show Gist options
  • Select an option

  • Save BernhardRode/1ac62d8cd337e5637e940ecbd73c3a5e to your computer and use it in GitHub Desktop.

Select an option

Save BernhardRode/1ac62d8cd337e5637e940ecbd73c3a5e to your computer and use it in GitHub Desktop.

Für github-dev-role:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::YOUR-ACCOUNT-ID:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringLike": {
          "token.actions.githubusercontent.com:sub": "repo:your-org/your-repo:environment:dev"
        }
      }
    }
  ]
}

Für github-prod-role:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::YOUR-ACCOUNT-ID:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringLike": {
          "token.actions.githubusercontent.com:sub": "repo:your-org/your-repo:environment:prod"
        }
      }
    }
  ]
}

GitHub Actions Workflow: In deinem Workflow kannst du dann je nach Bedarf die entsprechende Rolle assumen:

name: Deploy
on: [push]
jobs:
  deploy-dev:
    environment: dev
    permissions:
      id-token: write
    steps:
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::YOUR-ACCOUNT-ID:role/github-dev-role
          aws-region: eu-central-1

  deploy-prod:
    environment: prod
    permissions:
      id-token: write
    steps:
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::YOUR-ACCOUNT-ID:role/github-prod-role
          aws-region: eu-central-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment