GitHub: One command to authorize GitHub Actions to deploy to AWS

GitHub: One command to authorize GitHub Actions to deploy to AWS

https://github.com/mnapoli/github-to-aws

AdministratorAccess policy? Really?

This is neat, but seems to be the same as just running aws cloudformation deploy on the included CFN template. Is the script doing something beyond that that I’m missing?

Makes you wonder what other shortcuts have been taken..

It’s already one command to authenticate to AWS via OIDC using the official AWS action

Yeah, but that requires things such as creating the IAM role to assume and adding the necessary actions to your pipeline. He wrote this tool to automate/boilerplate that part.

As an ex-AWS employee and having written a bunch of tools for developers targeting AWS, let me tell you that least-privileges security is _complicated_. Not conceptually, mind you; it’s the process of knowing exactly what permissions you actually need and adding (and removing!) them as those needs change that’s difficult. I will point out that many of AWS’ own examples (and official docs for some services!!) use AdministratorAccess.

This guy’s tool is trying to simplify something that’s quite complex, so, yeah, he threw God Mode at it. The only notes I have for the author is that he should have called that out and explained that it’s in your best interest to learn how to reduce the permissions.

He packaged up a few steps and made it spit out the boilerplate for your pipeline so I think there’s some value added, here. But yes, if you already understand the steps needed to set up OICD in GHA, then this may not be something you care much about.

Great tool, thank you for sharing. I have two questions:

  1. is the intent to manage all authorized repos in this single repo or do we create this template once per repo?

  2. Is the thumbprint necessary: https://github.com/aws-actions/configure-aws-credentials?tab=readme-ov-file#configuring-iam-to-trust-github

The thumbprint is used by AWS to automatically trust new certificates signed by the same CA.

https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html

please read the documentation i provided. In most cases what you say is true but a special case is made for AWS.

the posted documents indicate that we can pass any arbitrary thumbprint

Really love your work with bref.sh /u/mnapoli <3

Mmh it seems like you missed the point of the repository, it’s about creating the role needed for the official OIDC support.

:heart:

The documentation says the fingerprint is not used for token.actions.githubusercontent.com because it is a Well-Known Provider. But, 1) still required and 2) not a forever guarauntee.

A special case is made for GitHub, not AWS.

That’s a good point, it’s mostly about DX and hiding the complexity for non-AWS experts. Here’s the CLI output for example, it guides you on setting up GitHub Actions with the right values:

The org/repo GitHub repository will be authorized to access AWS account 123456789 in us-east-1.
This will be done by deploying an IAM role using CloudFormation (stack name: “github-deploy-org-repo”) using the xxxx profile.

Do you want to continue? y

✔ Role deployed

Role ARN: arn:aws:iam::123456789:role/github-deploy-org-repo

You can now add these lines to your GitHub Actions file (for example .github/workflows/deploy.yml):

permissions:
    id-token: write # This is required for requesting the JWT
    contents: read  # This is required for actions/checkout
jobs:
    deploy:
        steps:
            # ...
            -   name: Configure AWS credentials
                uses: aws-actions/configure-aws-credentials@v4
                with:
                    role-to-assume: arn:aws:iam::123456789:role/github-deploy-org-repo
                    role-session-name: github-deploy
                    aws-region: us-east-1

Yeah good point! I found it really frustrating to setup OIDC on many repositories so I wanted to simplify the experience. It can 100% be improved (especially adminaccess…), but I wanted to share what I had instead of waiting (forever) for it to be perfect. Now it’s in the open and open to contributions.

Especially since it’s really hard to come up with good permissions. But /u/hoppersoft makes a very good point about adding a big fat warning to the README, I’ll do that now :+1:

thanks for the clarification

As an example of how difficult least-privilege can be, a year or so ago the CDK team gave up on constraining the permissions for CDK’s default lookup role, and just threw ReadOnly at it.

Bro fuck the haters yo, you did something good here