To allow the GitHub Actions runner to manage the EC2 build infrastructure (launching instances, managing security groups, and interacting with S3), create an IAM user (or use OIDC federation) with the following policy. Replace BUCKET_NAME with your actual S3 bucket name.
Required Permissions Summary:
- EC2 Management: Describe VPCs/Subnets/Security Groups, Create Security Groups, Run/Terminate Instances, and Create Tags.
- SSM: Fetch the latest Amazon Linux 2023 AMI ID.
- IAM:
iam:PassRole to attach the chromium-build instance profile to the EC2 instance. - S3: Full access (
PutObject, GetObject, DeleteObject, ListBucket) to the specified build bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EC2BuildManagement",
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:CreateSecurityGroup",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DescribeInstanceTypeOfferings",
"ec2:RunInstances",
"ec2:DescribeInstances",
"ec2:TerminateInstances",
"ec2:CreateTags"
],
"Resource": "*"
},
{
"Sid": "SSMReadAMI",
"Effect": "Allow",
"Action": "ssm:GetParameters",
"Resource": "arn:aws:ssm:*:*:parameter/aws/service/ami-amazon-linux-latest/*"
},
{
"Sid": "IAMPassRole",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::*:role/chromium-build"
},
{
"Sid": "S3ArtifactAccess",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": ["arn:aws:s3:::BUCKET_NAME", "arn:aws:s3:::BUCKET_NAME/*"]
}
]
}