-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy paths3.template.yml
105 lines (104 loc) · 3.55 KB
/
s3.template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
AWSTemplateFormatVersion: '2010-09-09'
Resources:
CodeGuruReviewerBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: codeguru-reviewer-my-bucket
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
CodeGuruReviewerCICDActionsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
PolicyDocument:
Id: S3BucketPolicy
Version: '2012-10-17'
Statement:
- Sid: DenyPublicReadACL
Effect: Deny
Principal:
AWS: "*"
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}"
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
Condition:
StringEquals:
s3:x-amz-acl:
- public-read
- public-read-write
- authenticated-read
- Sid: DenyPublicReadGrant
Effect: Deny
Principal:
AWS: "*"
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}"
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
Condition:
StringEquals:
s3:x-amz-grant-read:
- "*http://acs.amazonaws.com/groups/global/AllUsers*"
- "*http://acs.amazonaws.com/groups/global/AuthenticatedUsers*"
- Sid: DenyPublicListACL
Effect: Deny
Principal:
AWS: "*"
Action: s3:PutBucketAcl
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}"
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
Condition:
StringEquals:
s3:x-amz-acl:
- public-read
- public-read-write
- authenticated-read
- Sid: DenyPublicListGrant
Effect: Deny
Principal:
AWS: "*"
Action: s3:PutBucketAcl
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}"
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
Condition:
StringEquals:
s3:x-amz-grant-read:
- "*http://acs.amazonaws.com/groups/global/AllUsers*"
- "*http://acs.amazonaws.com/groups/global/AuthenticatedUsers*"
- Sid: DenyInSecureRequest
Effect: Deny
Principal: "*"
Action: s3:*
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}"
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
Condition:
Bool:
aws:SecureTransport: 'false'
- Sid: AllowS3WriteAccess
Effect: Allow
Principal:
AWS: arn:aws:iam::<aws_account_id>:root
Action: s3:PutObject
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
- Sid: DenyS3ReadAccess
Effect: Deny
Principal: "*"
Action: s3:GetObject
Resource:
- Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*"
Condition:
StringNotLike:
aws:PrincipalArn: arn:aws:iam::<aws_account_id>:role/aws-service-role/codeguru-reviewer.amazonaws.com/AWSServiceRoleForAmazonCodeGuruReviewer
Bucket:
Ref: CodeGuruReviewerBucket