Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assume role #16

Open
Andrew-Chen-Wang opened this issue Mar 20, 2023 · 1 comment
Open

Use assume role #16

Andrew-Chen-Wang opened this issue Mar 20, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Andrew-Chen-Wang
Copy link
Owner

Andrew-Chen-Wang commented Mar 20, 2023

Much easier, more secure

    - name: Configure AWS credentials
      # Visit https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
      # to learn how to set this up
      uses: aws-actions/configure-aws-credentials@v1
      with:
        role-to-assume: arn:aws:iam::1234567890:role/role-name
        aws-region: us-east-1

To make it work properly:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::1234567890:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "ForAllValues:StringEquals": {
                    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
                    "token.actions.githubusercontent.com:iss": "https://token.actions.githubusercontent.com"
                    "token.actions.githubusercontent.com:sub": "repo:Org-Case-Sensitive/rEpo:ref:refs/heads/main"
                }
            }
        }
    ]
}
@Andrew-Chen-Wang
Copy link
Owner Author

for multiple sub, you can make an array. Additional note is that you need:

permissions:
  id-token: write
  contents: read

in your job or top level of workflow

@Andrew-Chen-Wang Andrew-Chen-Wang added the enhancement New feature or request label Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant