Skip to content

Commit c5edcd2

Browse files
committed
Update IAM policies for AWS SAM deployment
- Update CloudFormation resources to include SAM managed stack - Update S3 resources for SAM managed bucket - Clean up Serverless-specific permissions
1 parent d091940 commit c5edcd2

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

backend/iam/existing_stack.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This is the IAM policy needed to update an existing stack in CI, if there are no new functions added.
2-
# (replace ${account_id} with your Amazon Account ID)
1+
# IAM policy for CI to update an existing AWS SAM stack (no new functions).
2+
# Replace ${account_id} with your AWS Account ID.
33

44
{
55
"Version": "2012-10-17",
@@ -23,12 +23,11 @@
2323
"s3:PutObject",
2424
"s3:DeleteObject",
2525
"s3:ListBucket",
26-
"s3:GetEncryptionConfiguration",
27-
"s3:GetBucketPolicy",
28-
"s3:GetBucketAcl"
26+
"s3:GetBucketLocation"
2927
],
3028
"Resource": [
31-
"arn:aws:s3:::cryfs-web-backend-*"
29+
"arn:aws:s3:::aws-sam-cli-managed-default-samclisourcebucket-*",
30+
"arn:aws:s3:::aws-sam-cli-managed-default-samclisourcebucket-*/*"
3231
]
3332
},
3433
{
@@ -42,10 +41,12 @@
4241
"cloudformation:DescribeStackEvents",
4342
"cloudformation:ListStackResources",
4443
"cloudformation:CreateChangeSet",
45-
"cloudformation:DeleteChangeSet"
44+
"cloudformation:DeleteChangeSet",
45+
"cloudformation:GetTemplateSummary"
4646
],
4747
"Resource": [
48-
"arn:aws:cloudformation:us-east-1:${account_id}:stack/cryfs-web-backend-*"
48+
"arn:aws:cloudformation:us-east-1:${account_id}:stack/cryfs-web-backend/*",
49+
"arn:aws:cloudformation:us-east-1:${account_id}:stack/aws-sam-cli-managed-default/*"
4950
]
5051
},
5152
{
@@ -55,9 +56,7 @@
5556
"cloudformation:GetTemplate",
5657
"cloudformation:ValidateTemplate"
5758
],
58-
"Resource": [
59-
"*"
60-
]
59+
"Resource": "*"
6160
},
6261
{
6362
"Sid": "Lambda",

backend/iam/new_stack.txt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This is the IAM policy needed to deploy a new stack (i.e. when AWS Lambda is being set up from scratch) or a new function
2-
# (replace ${account_id} with your Amazon Account ID)
1+
# IAM policy for CI to deploy a new AWS SAM stack or add new functions.
2+
# Replace ${account_id} with your AWS Account ID.
33

44
{
55
"Version": "2012-10-17",
@@ -31,16 +31,16 @@
3131
"s3:ListBucket",
3232
"s3:CreateBucket",
3333
"s3:DeleteBucket",
34-
"s3:GetEncryptionConfiguration",
34+
"s3:GetBucketLocation",
3535
"s3:PutEncryptionConfiguration",
36-
"s3:GetBucketPolicy",
3736
"s3:PutBucketPolicy",
3837
"s3:PutBucketTagging",
39-
"s3:GetBucketAcl",
40-
"s3:PutBucketAcl"
38+
"s3:PutBucketVersioning",
39+
"s3:PutLifecycleConfiguration"
4140
],
4241
"Resource": [
43-
"arn:aws:s3:::cryfs-web-backend-*"
42+
"arn:aws:s3:::aws-sam-cli-managed-default-samclisourcebucket-*",
43+
"arn:aws:s3:::aws-sam-cli-managed-default-samclisourcebucket-*/*"
4444
]
4545
},
4646
{
@@ -54,10 +54,12 @@
5454
"cloudformation:CreateChangeSet",
5555
"cloudformation:ExecuteChangeSet",
5656
"cloudformation:DescribeStackEvents",
57-
"cloudformation:ListStackResources"
57+
"cloudformation:ListStackResources",
58+
"cloudformation:GetTemplateSummary"
5859
],
5960
"Resource": [
60-
"arn:aws:cloudformation:us-east-1:${account_id}:stack/cryfs-web-backend-*"
61+
"arn:aws:cloudformation:us-east-1:${account_id}:stack/cryfs-web-backend/*",
62+
"arn:aws:cloudformation:us-east-1:${account_id}:stack/aws-sam-cli-managed-default/*"
6163
]
6264
},
6365
{
@@ -67,9 +69,7 @@
6769
"cloudformation:GetTemplate",
6870
"cloudformation:ValidateTemplate"
6971
],
70-
"Resource": [
71-
"*"
72-
]
72+
"Resource": "*"
7373
},
7474
{
7575
"Sid": "Lambda",
@@ -84,7 +84,8 @@
8484
"lambda:ListVersionsByFunction",
8585
"lambda:PublishVersion",
8686
"lambda:UpdateFunctionCode",
87-
"lambda:AddPermission"
87+
"lambda:AddPermission",
88+
"lambda:RemovePermission"
8889
],
8990
"Resource": "arn:aws:lambda:us-east-1:${account_id}:function:cryfs-web-backend-*"
9091
},

0 commit comments

Comments
 (0)