Step by step approach for creation of IAM Role in AWS and using in GitHub Actions Pipeline
Step1 : Create of Identity Provider for Github
Step2: Select the OpenIDConnect then give the necessary details as given below and then click on Add Provider
- For the provider URL: Use https://token.actions.githubusercontent.com
- For the "Audience": Use sts.amazonaws.com
Step3: Creation of IAM Role using Open ID Connector
Step 3.1:
Step 3.2:
- Select Identity Provider
- Select Audience
- Enter GitHub Organisation
Step 3.3: Select required permissions
Step 3.4: Enter the role name as GHOIDCRole then click on create role
Step 3.5: Keep the IAM Role handy and its needs to be included to be used in GitHub Pipeline
- arn:aws:iam::AWS_Account_ID:role/GHOIDCRole
Step 4: Create a github repo under your Github organisation
Step 4.1 : click on Actions
Step 4.2 :
To create a GitHub action to invoke the AWS CLI:
Create a basic workflow file, such as main.yml, in the .github/workflows directory of your repository. This sample workflow will assume the GHOIDCRole role, to perform the action aws sts get-caller-identity. Your repository can have multiple workflows, each performing different sets of tasks. After GitHub is authenticated to the role with the workflow, you can use AWS CLI commands in your account.
Paste the following example workflow into the file.
# This is a basic workflow to help you get started with Actions
name:Connect to an AWS role from a GitHub repository
# Controls when the action will run. Invokes the workflow on push events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
AWS_REGION : <"us-east-1"> #Change to reflect your Region
# Permission can be added at job level or
Top comments (3)
Great walkthrough on setting up OpenID Connect with GitHub Actions! This really simplifies AWS authentication without long-lived credentials. Thanks for sharing!
thanks @joanne skiles. But wait for 1 or 2 days to finish the article with sample github pipeline
I've done all this with my pipelines, I just appreciate this all written in one place.