1. Go to AWS IAM console.
2. In the left sidebar,
3. In the Configure provider section,
https://token.actions.githubusercontent.com
.sts.amazonaws.com
.4. Scroll down to the bottom, click Add provider.
5. Back to AWS IAM console.
6. In the left sidebar,
7. In the Policy editor section,
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPushPull",
"Effect": "Allow",
"Action": [
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:CompleteLayerUpload",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart",
"ecr:DescribeImages"
],
"Resource": "arn:aws:ecr:us-east-1:<YOUR-AWS-ACCOUNT-ID>:repository/awsome-books"
},
{
"Sid": "GetAuthorizationToken",
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken"
],
"Resource": "*"
},
{
"Sid": "RegisterAndDescribeTaskDefinition",
"Effect": "Allow",
"Action": [
"ecs:RegisterTaskDefinition",
"ecs:DescribeTaskDefinition"
],
"Resource": "*"
},
{
"Sid": "PassRolesInTaskDefinition",
"Effect": "Allow",
"Action": [
"iam:PassRole"
],
"Resource": [
"arn:aws:iam::<YOUR-AWS-ACCOUNT-ID>:role/ecsTaskRole",
"arn:aws:iam::<YOUR-AWS-ACCOUNT-ID>:role/ecsTaskExecutionRole"
]
},
{
"Sid": "DeployService",
"Effect": "Allow",
"Action": [
"ecs:UpdateService",
"ecs:DescribeServices",
"codedeploy:GetDeploymentGroup",
"codedeploy:CreateDeployment",
"codedeploy:GetDeployment",
"codedeploy:GetDeploymentConfig",
"codedeploy:RegisterApplicationRevision"
],
"Resource": [
"arn:aws:ecs:us-east-1:<YOUR-AWS-ACCOUNT-ID>:service/fcj/awsome-books",
"arn:aws:codedeploy:us-east-1:<YOUR-AWS-ACCOUNT-ID>:deploymentgroup:AppECS-fcj-awsome-books/DgpECS-fcj-awsome-books",
"arn:aws:codedeploy:us-east-1:<YOUR-AWS-ACCOUNT-ID>:deploymentconfig:*",
"arn:aws:codedeploy:us-east-1:<YOUR-AWS-ACCOUNT-ID>:application:AppECS-fcj-awsome-books"
]
}
]
}
8. Scroll down to the bottom, click Next.
9. In the Policy details section, enter gha-policy
for Policy name.
10. Scroll down to the bottom, click Create policy.
11. Back to AWS IAM console.
12. In the left sidebar,
13. In the Trusted entity type section, select Web identity.
14. In the Web identity section,
fcj-workshops-2024
.awsome-books
.15. In the Permissions policies section,
gha-policy
.16. In the Role details section, enter gha-role
for Role name.
17. Scroll down to the bottom, click Create role.
18. Note down the role ARN you just created — you may need it later!