Create IAM Role

  1. In the Identity Providers choose the Provider we just created
4-iam
  1. Choose “Assign role”
5-iam
  1. Choose “Create a new role” -> “Next”
6-iam
  1. At the Step 1
    • At Trusted Entity type we choose “Web identity”
    • At Web Identity:
      • Choose Identity Provider https://token.actions.githubusercontent.com
      • Choose Audience sts.amazonaws.com
      • Github Organization: Fill your github username (This name is case sensitive)
      • Click Next
7-iam
  1. At the Step 2 is AWS Managed Policy but we will create inline policy so we choose “Next”
8-iam
  1. At the Step 3 you will fill your role name like images and remember that role for later
8.1-iam
  1. Click “Create role”
9-iam
  1. At the left menu choose “Roles” -> Search your created role -> Choose that role
10-iam
  1. At the Permission Policies -> Choose “Add permissions” -> Create inline policy
11-iam
  1. At Step 1 choose JSON and copy paste the following policy (Remember change these ID for your case):
{
 "Version": "2012-10-17",
 "Statement": [
  {
   "Sid": "SyncToBucket",
   "Effect": "Allow",
   "Action": [
    "s3:PutObject",
    "s3:GetObject",
    "s3:ListBucket",
    "s3:DeleteObject"
   ],
   "Resource": [
    "arn:aws:s3:::YOUR_BUCKET_NAME/*",
    "arn:aws:s3:::YOUR_BUCKET_NAME"
   ]
  },
  {
   "Sid": "FlushCache",
   "Effect": "Allow",
   "Action": "cloudfront:CreateInvalidation",
   "Resource": "arn:aws:cloudfront::YOUR_ACCOUNT_ID:distribution/YOUR_CLOUDFRONT_ID"
  }
 ]
}
12-iam

Then click “Next” -> “Save Changes”