unfunco / terraform-aws-oidc-github

Terraform module to configure GitHub Actions as an IAM OIDC identity provider in AWS.
https://registry.terraform.io/modules/unfunco/oidc-github/aws/latest
Apache License 2.0
91 stars 51 forks source link

Add optional variable 'github_ref', to allow actions only from specif… #9

Closed nick-doyle-slalom closed 2 years ago

nick-doyle-slalom commented 2 years ago

…ic branches

Specifying this will make the AssumeRole StringLike's condition require a specific ref e.g. 'repo:myorg/myrepo:ref:refs/heads/prod'

Not setting this will default to "all refs" ('repo:myorg/myrepo:*') per existing behaviour

More details https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#configuring-the-subject-in-your-cloud-provider

unfunco commented 2 years ago

Hello, thank you for this, it's something I've been wanting to add for a while. The issue with this implementation is that it would apply to all repositories specified in github_repositories. I think it might be better to expand the regex in the github_repositories condition to allow an optional ref to be specified, and then in data.tf when it's looping through the repositories, check for a : to determine whether to use the ref or an * – what do you think?