configure-aws-credentials icon indicating copy to clipboard operation
configure-aws-credentials copied to clipboard

GitHub OIDC trust condition

Open drey0143143 opened this issue 3 years ago • 1 comments

I would like to create a Trust relationship for an AWS Role Federated from GitHub via OIDC that restrict access to request token based on the 2 conditions below. a pull request to master in this repo a push to master in this repo

I currently have the below condition working but struggling to restrict the permissions to the Role in AWS to only a pull request to master (and not to any branch)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "ForAnyValue:StringLike": {
                    "token.actions.githubusercontent.com:sub": [
                        "repo:opeville/identity-opeville:ref:refs/heads/master",
                        "repo:opeville/identity-opeville:pull_request"
                    ]
                }
            }
        }
    ]
}

drey0143143 avatar Feb 11 '22 14:02 drey0143143

I might be way off with this suggestion, but would it be worth doing this on the GH actions side? Something like

on:
  pull_request_target:
    types:
      - opened
    branches:    
      - 'master'
  push:
    branches:    
      - 'master'

Reference: GH docs

VariableExp0rt avatar Mar 21 '22 13:03 VariableExp0rt

Closing in favor of https://github.com/aws-actions/configure-aws-credentials/issues/390, thanks for the issue submission!

peterwoodworth avatar Oct 10 '22 23:10 peterwoodworth

⚠️Comment Visibility Warning⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Oct 10 '22 23:10 github-actions[bot]

Sorry, there's another related issue I meant to link to. https://github.com/aws-actions/configure-aws-credentials/issues/454

The last issue I linked isn't a direct duplicate since that feature request won't work for OIDC

peterwoodworth avatar Oct 11 '22 02:10 peterwoodworth