Skip to content

Commit 2bfc2cc

Browse files
committed
Remove duplicated permissions from custom policy
* The custom IAM policy used by the GitHub workflows contains very fine-granular permissions. Whenever a new resource is added, it is quite cumbersome to find out all the detailed permissions that are required to manage this resource. * For this reason, two AWS-managed policies were added to the role that grant generic read-only permission as well as permissions to tag and untag resources. Some fine-granular permissions in the custom policy are now no longer needed.
1 parent 1da7bf5 commit 2bfc2cc

2 files changed

Lines changed: 12 additions & 114 deletions

File tree

docs/disaster-recovery.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,14 @@ RAILS_ENV=staging bin/bundle exec \
195195
EXPORT_PASSWORD=secure \
196196
node ./script/encrypt_xlsx.mjs <filename>
197197
```
198+
199+
200+
## Set up a new AWS account from scratch
201+
202+
### Create a new IAM role for GitHub workflows
203+
204+
In the AWS IAM console, create a new role for the GitHub workflows. Create a custom policy from `terraform/resources/github_actions_policy.json`. Also, attach the managed policies
205+
- `ReadOnlyAccess`
206+
- `ResourceGroupsTaggingAPITagUntagSupportedResources`
207+
208+
to the role.

terraform/resources/github_actions_policy.json

Lines changed: 1 addition & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,16 @@
55
"Sid": "Statement1",
66
"Effect": "Allow",
77
"Action": [
8-
"acm:AddTagsToCertificate",
98
"acm:DeleteCertificate",
10-
"acm:DescribeCertificate",
11-
"acm:ListTagsForCertificate",
129
"acm:RequestCertificate",
13-
"cloudformation:DescribeStacks",
14-
"cloudformation:GetTemplateSummary",
15-
"cloudformation:ListStackInstances",
1610
"codedeploy:CreateApplication",
1711
"codedeploy:CreateDeployment",
1812
"codedeploy:CreateDeploymentGroup",
1913
"codedeploy:DeleteApplication",
2014
"codedeploy:DeleteDeploymentGroup",
21-
"codedeploy:GetApplication",
22-
"codedeploy:GetApplicationRevision",
23-
"codedeploy:GetDeployment",
24-
"codedeploy:GetDeploymentConfig",
25-
"codedeploy:GetDeploymentGroup",
26-
"codedeploy:ListDeployments",
27-
"codedeploy:ListTagsForResource",
2815
"codedeploy:RegisterApplicationRevision",
2916
"codedeploy:UpdateDeploymentGroup",
30-
"codedeploy:TagResource",
31-
"codedeploy:UntagResource",
3217
"codedeploy:UpdateApplication",
33-
"dynamodb:GetItem",
3418
"dynamodb:PutItem",
3519
"dynamodb:DeleteItem",
3620
"ec2:AllocateAddress",
@@ -45,7 +29,6 @@
4529
"ec2:CreateRouteTable",
4630
"ec2:CreateSecurityGroup",
4731
"ec2:CreateSubnet",
48-
"ec2:CreateTags",
4932
"ec2:CreateVpc",
5033
"ec2:DeleteFlowLogs",
5134
"ec2:DeleteInternetGateway",
@@ -55,36 +38,15 @@
5538
"ec2:DeleteSecurityGroup",
5639
"ec2:DeleteSubnet",
5740
"ec2:DeleteVpc",
58-
"ec2:DescribeAccountAttributes",
59-
"ec2:DescribeAddresses",
60-
"ec2:DescribeAddressesAttribute",
61-
"ec2:DescribeAvailabilityZones",
62-
"ec2:DescribeFlowLogs",
63-
"ec2:DescribeInternetGateways",
64-
"ec2:DescribeNatGateways",
65-
"ec2:DescribeNetworkAcls",
66-
"ec2:DescribeNetworkInterfaces",
67-
"ec2:DescribeRouteTables",
68-
"ec2:DescribeSecurityGroupRules",
69-
"ec2:DescribeSecurityGroups",
70-
"ec2:DescribeSubnets",
71-
"ec2:DescribeVpcAttribute",
72-
"ec2:DescribeVpcs",
7341
"ec2:DetachInternetGateway",
7442
"ec2:DetachNetworkInterface",
7543
"ec2:DisassociateAddress",
7644
"ec2:DisassociateRouteTable",
77-
"ec2:GetSecurityGroupsForVpc",
7845
"ec2:ModifyVpcAttribute",
7946
"ec2:ReleaseAddress",
8047
"ec2:RevokeSecurityGroupEgress",
8148
"ec2:RevokeSecurityGroupIngress",
82-
"ecr:BatchCheckLayerAvailability",
83-
"ecr:BatchGetImage",
8449
"ecr:CompleteLayerUpload",
85-
"ecr:DescribeImages",
86-
"ecr:GetAuthorizationToken",
87-
"ecr:GetDownloadUrlForLayer",
8850
"ecr:InitiateLayerUpload",
8951
"ecr:PutImage",
9052
"ecr:UploadLayerPart",
@@ -93,14 +55,8 @@
9355
"ecs:DeleteCluster",
9456
"ecs:DeleteService",
9557
"ecs:DeregisterTaskDefinition",
96-
"ecs:DescribeClusters",
97-
"ecs:DescribeServices",
98-
"ecs:DescribeTaskDefinition",
9958
"ecs:RegisterTaskDefinition",
10059
"ecs:UpdateService",
101-
"ecs:TagResource",
102-
"ecs:UntagResource",
103-
"elasticloadbalancing:AddTags",
10460
"elasticloadbalancing:CreateListener",
10561
"elasticloadbalancing:CreateLoadBalancer",
10662
"elasticloadbalancing:CreateRule",
@@ -109,122 +65,53 @@
10965
"elasticloadbalancing:DeleteLoadBalancer",
11066
"elasticloadbalancing:DeleteRule",
11167
"elasticloadbalancing:DeleteTargetGroup",
112-
"elasticloadbalancing:DescribeListenerAttributes",
113-
"elasticloadbalancing:DescribeListeners",
114-
"elasticloadbalancing:DescribeListenerCertificates",
115-
"elasticloadbalancing:DescribeLoadBalancerAttributes",
116-
"elasticloadbalancing:DescribeLoadBalancers",
117-
"elasticloadbalancing:DescribeRules",
118-
"elasticloadbalancing:DescribeTags",
119-
"elasticloadbalancing:DescribeTargetGroupAttributes",
120-
"elasticloadbalancing:DescribeTargetGroups",
12168
"elasticloadbalancing:ModifyListener",
12269
"elasticloadbalancing:ModifyListenerAttributes",
12370
"elasticloadbalancing:ModifyLoadBalancerAttributes",
12471
"elasticloadbalancing:ModifyRule",
12572
"elasticloadbalancing:ModifyTargetGroupAttributes",
12673
"iam:AttachRolePolicy",
12774
"iam:CreatePolicyVersion",
128-
"iam:GetRole",
12975
"iam:PassRole",
130-
"iam:ListRolePolicies",
131-
"iam:ListAttachedRolePolicies",
132-
"iam:ListInstanceProfilesForRole",
133-
"iam:ListPolicyVersions",
134-
"iam:GetPolicy",
13576
"iam:CreateRole",
13677
"iam:CreatePolicy",
13778
"iam:DeleteRole",
13879
"iam:DeletePolicy",
139-
"iam:GetPolicyVersion",
14080
"iam:DetachRolePolicy",
141-
"iam:TagPolicy",
142-
"iam:TagRole",
14381
"kms:CreateGrant",
14482
"kms:Decrypt",
145-
"kms:DescribeKey",
14683
"logs:CreateLogGroup",
14784
"logs:DeleteLogGroup",
148-
"logs:DescribeLogGroups",
149-
"logs:ListTagsForResource",
15085
"logs:PutRetentionPolicy",
15186
"rds:CreateDBCluster",
15287
"rds:CreateDBInstance",
15388
"rds:CreateDBSubnetGroup",
15489
"rds:DeleteDBCluster",
15590
"rds:DeleteDBInstance",
15691
"rds:DeleteDBSubnetGroup",
157-
"rds:DescribeDBClusters",
158-
"rds:DescribeDBInstances",
159-
"rds:DescribeDBSubnetGroups",
160-
"rds:DescribeGlobalClusters",
161-
"rds:ListTagsForResource",
162-
"rds:AddTagsToResource",
16392
"rds:ModifyDBCluster",
16493
"rds:ModifyCurrentDBClusterCapacity",
16594
"rds:ModifyDBInstance",
166-
"rds:RemoveTagsFromResource",
16795
"resource-groups:CreateGroup",
16896
"resource-groups:DeleteGroup",
169-
"resource-groups:GetGroup",
170-
"resource-groups:GetGroupConfiguration",
171-
"resource-groups:GetGroupQuery",
172-
"resource-groups:GetTags",
173-
"resource-groups:Tag",
17497
"route53:ChangeResourceRecordSets",
17598
"route53:CreateHostedZone",
176-
"route53:GetChange",
177-
"route53:GetHostedZone",
178-
"route53:ListHostedZones",
179-
"route53:ListResourceRecordSets",
180-
"route53:ListTagsForResource",
18199
"s3:CreateBucket",
182100
"s3:DeleteBucket",
183101
"s3:DeleteBucketPolicy",
184102
"s3:DeleteObject",
185103
"s3:DeleteObjectVersion",
186-
"s3:GetAccelerateConfiguration",
187-
"s3:GetBucketAcl",
188-
"s3:GetBucketCors",
189-
"s3:GetBucketCORS",
190-
"s3:GetBucketLogging",
191-
"s3:GetBucketObjectLockConfiguration",
192-
"s3:GetBucketPolicy",
193-
"s3:GetBucketPublicAccessBlock",
194-
"s3:GetBucketRequestPayment",
195-
"s3:GetBucketTagging",
196-
"s3:GetBucketVersioning",
197-
"s3:GetBucketWebsite",
198-
"s3:GetEncryptionConfiguration",
199-
"s3:GetObject",
200-
"s3:GetObjectTagging",
201-
"s3:GetLifecycleConfiguration",
202-
"s3:ListBucket",
203-
"s3:ListBucketVersions",
204104
"s3:PutBucketLogging",
205105
"s3:PutBucketPolicy",
206106
"s3:PutBucketPublicAccessBlock",
207-
"s3:PutBucketTagging",
208107
"s3:PutBucketVersioning",
209108
"s3:PutObject",
210-
"s3:PutObjectTagging",
211-
"s3:GetReplicationConfiguration",
212-
"s3:TagResource",
213-
"s3:UntagResource",
214109
"secretsmanager:CreateSecret",
215110
"secretsmanager:PutSecretValue",
216111
"secretsmanager:UpdateSecret",
217-
"secretsmanager:TagResource",
218-
"secretsmanager:UntagResource",
219-
"ssm:AddTagsToResource",
220112
"ssm:DeleteParameter",
221113
"ssm:DeleteParameters",
222-
"ssm:DescribeParameters",
223-
"ssm:GetParameter",
224-
"ssm:GetParameters",
225-
"ssm:ListTagsForResource",
226-
"ssm:PutParameter",
227-
"sts:GetCallerIdentity"
114+
"ssm:PutParameter"
228115
],
229116
"Resource": ["*"]
230117
}

0 commit comments

Comments
 (0)