Skip to content

Commit fea64bc

Browse files
author
sg
committedJun 20, 2024
improve naming
1 parent 2219df2 commit fea64bc

6 files changed

+19
-19
lines changed
 

‎.github/workflows/cdk-deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Configure AWS Creds
4343
uses: aws-actions/configure-aws-credentials@v4
4444
with:
45-
role-to-assume: "arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GitHubActions"
45+
role-to-assume: "arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GithubActions"
4646
aws-region: ${{ secrets.AWS_REGION }}
4747

4848
- name: Deploy CDK

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AWS + Github Actions with OIDC
22

3-
This project is a TypeScript-based AWS CDK application that sets up an OpenID Connect (OIDC) provider for GitHub Actions, creates an IAM role for GitHub Actions to assume, and attaches necessary policies to the IAM role.
3+
This project is a TypeScript-based AWS CDK application that sets up an OpenID Connect (OIDC) provider for Github Actions, creates an IAM role for Github Actions to assume, and attaches necessary policies to the IAM role.
44

55
## Getting Started
66

@@ -41,7 +41,7 @@ npm test
4141

4242
## Deployment
4343

44-
This project uses GitHub Actions for deployment. The workflow is defined in `.github/workflows/cdk-deploy.yml`. It is triggered manually, on push to the main branch, or on pull requests to the main branch.
44+
This project uses Github Actions for deployment. The workflow is defined in `.github/workflows/cdk-deploy.yml`. It is triggered manually, on push to the main branch, or on pull requests to the main branch.
4545

4646
## Built With
4747

‎bin/gh-aws-deploy-oidc.ts ‎bin/app.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { GithubActionsPolicyStack } from '../lib/github-actions-policy-stack';
88
const app = new App();
99

1010
// Create the OIDC provider stack
11-
// This stack sets up the OpenID Connect provider for GitHub Actions
11+
// This stack sets up the OpenID Connect provider for Github Actions
1212
const oidcGithubProviderStack = new GithubOidcProviderStack(app, 'GithubOidcProvider');
1313

14-
// Create the GitHub Actions role stack
15-
// This stack creates an IAM role for GitHub Actions to assume
14+
// Create the Github Actions role stack
15+
// This stack creates an IAM role for Github Actions to assume
1616
// The role assumes the OIDC provider created in the previous stack
17-
const githubActionsRoleStack = new GithubActionsRoleStack(app, 'GithubActionsRole', oidcGithubProviderStack.oidcGithubProvider.openIdConnectProviderArn);
17+
const githubActionsRoleStack = new GithubActionsRoleStack(app, 'GithubActionsRole', oidcGithubProviderStack.GithubOIDCProvider.openIdConnectProviderArn);
1818

19-
// Create the GitHub Actions policy stack
19+
// Create the Github Actions policy stack
2020
// This stack attaches necessary policies to the IAM role created in the previous stack
2121
new GithubActionsPolicyStack(app, 'GithubActionsPolicy', githubActionsRoleStack.role);
2222

‎lib/github-actions-policy-stack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class GithubActionsPolicyStack extends cdk.Stack {
4949
sid: 'AllowCDKLambdaOperations'
5050
});
5151

52-
// Attach policies to the GitHub actions role
52+
// Attach policies to the github actions role
5353
role.addToPolicy(cdkDeploymentPolicy);
5454
role.addToPolicy(ec2OperationsPolicy);
5555
role.addToPolicy(lambdaOperationsPolicy);

‎lib/github-actions-role-stack.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ export class GithubActionsRoleStack extends cdk.Stack {
1010
constructor(scope: Construct, id: string, oidcProviderArn: string, props?: cdk.StackProps) {
1111
super(scope, id, props);
1212

13-
// Create a new IAM role for GitHub Actions to use
14-
this.role = new Role(this, 'GitHubActionsRole', {
13+
// Create a new IAM role for Github Actions to use
14+
this.role = new Role(this, 'GithubActionsRole', {
1515
// Specify the principal that can assume this role
16-
// Use the OIDC provider ARN for GitHub Actions
16+
// Use the OIDC provider ARN for Github Actions
1717
assumedBy: new FederatedPrincipal(oidcProviderArn, {
1818
StringEquals: {
1919
// Conditions for the OIDC provider
2020
'token.actions.githubusercontent.com:aud': 'sts.amazonaws.com',
2121
'token.actions.githubusercontent.com:sub': [
22-
// Sets the Username/Organization, Repo, and GitHub environments that AWS will allow to be deployed from.
22+
// Sets the Username/Organization, Repo, and Github environments that AWS will allow to be deployed from.
2323
// Only the specific repo and environment will be allowed, using temporary keys with OIDC.
2424
// CASE SENSITIVE!
2525
// 'repo:<USER/ORG_NAME>/<REPO>:environment:<GITHUB_ENV_NAME>'
2626
'repo:sghost13/gh-aws-deploy-oidc:environment:dev'
2727
]
2828
},
2929
},
30-
// The role action being assumed, allows a web identity(GitHub Runners) to assume the specified role.
30+
// The role action being assumed, allows a web identity(Github Runners) to assume the specified role.
3131
'sts:AssumeRoleWithWebIdentity'
3232
),
3333
// Description for the role
3434
description: 'Role for Github Actions to deploy using CDK',
3535
// Custom name for the role
36-
roleName: 'GitHubActions',
36+
roleName: 'GithubActions',
3737
// Maximum duration for the role session
3838
maxSessionDuration: cdk.Duration.hours(1),
3939
});

‎lib/github-oidc-provider-stack.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import { OpenIdConnectProvider } from 'aws-cdk-lib/aws-iam';
55
export class GithubOidcProviderStack extends cdk.Stack {
66

77
// Declare a public readonly property for the OIDC provider
8-
public readonly oidcGithubProvider: OpenIdConnectProvider;
8+
public readonly GithubOIDCProvider: OpenIdConnectProvider;
99

1010
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
1111
super(scope, id, props);
1212

1313
// Create a new OpenIdConnectProvider
14-
// This OIDC provider allows GitHub Actions Runners to interact with AWS services
14+
// This OIDC provider allows Github Actions Runners to interact with AWS services
1515
// Set when and how the interaction takes place in the policy/role
16-
this.oidcGithubProvider = new OpenIdConnectProvider(this, 'GithubOIDCProvider', {
17-
// The URL of the OIDC identity provider, in this case GitHub
16+
this.GithubOIDCProvider = new OpenIdConnectProvider(this, 'GithubOIDCProvider', {
17+
// The URL of the OIDC identity provider, in this case Github
1818
url: 'https://token.actions.githubusercontent.com',
1919
// The client IDs that are allowed to authenticate using this OIDC provide, in this case aws sts service
2020
clientIds: ['sts.amazonaws.com']

0 commit comments

Comments
 (0)
Please sign in to comment.