Last active
September 15, 2021 20:45
-
-
Save sebbel/89bd671f9d501a03e1b456d79358a656 to your computer and use it in GitHub Desktop.
GitHub Actions AWS Federation in CDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; | |
import * as iam from '@aws-cdk/aws-iam'; | |
const repo = "aws-cdk"; | |
const owner = "aws"; | |
export class GithubFederation extends Stack { | |
constructor(scope: Construct, id: string, props: StackProps = {}) { | |
super(scope, id, props); | |
const githubOIDC = new iam.CfnOIDCProvider(this, "GitHubOIDC", { | |
url: "https://vstoken.actions.githubusercontent.com", | |
clientIdList: ["sigstore"], | |
thumbprintList: ["a031c46782e6e6c662c2c87c76da9aa62ccabd8e"] | |
}) | |
new iam.Role(this, 'ExampleGithubRole', { | |
roleName: "ExampleGithubRole", | |
assumedBy: new iam.WebIdentityPrincipal(githubOIDC.ref, { | |
"StringLike": { | |
"vstoken.actions.githubusercontent.com:sub": `repo:${owner}/${repo}:*` | |
} | |
}), | |
}) | |
}}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment