1+ {
2+ "TestBucketWithRoles" : {
3+ "Properties" : {
4+ "BucketName" : " test-bucket-with-roles" ,
5+ "BucketEncryption" : {
6+ "ServerSideEncryptionConfiguration" : [
7+ {
8+ "ServerSideEncryptionByDefault" : {
9+ "SSEAlgorithm" : " AES256"
10+ }
11+ }
12+ ]
13+ },
14+ "PublicAccessBlockConfiguration" : {
15+ "BlockPublicAcls" : true ,
16+ "BlockPublicPolicy" : true ,
17+ "IgnorePublicAcls" : true ,
18+ "RestrictPublicBuckets" : true
19+ },
20+ "VersioningConfiguration" : {
21+ "Status" : " Enabled"
22+ }
23+ },
24+ "Type" : " AWS::S3::Bucket"
25+ },
26+ "TestBucketWithRolesPolicy" : {
27+ "Properties" : {
28+ "Bucket" : {
29+ "Ref" : " TestBucketWithRoles"
30+ },
31+ "PolicyDocument" : {
32+ "Version" : " 2012-10-17" ,
33+ "Statement" : [
34+ {
35+ "Effect" : " Deny" ,
36+ "Principal" : {
37+ "AWS" : " *"
38+ },
39+ "Action" : " s3:*" ,
40+ "Resource" : " arn:aws:s3:::test-bucket-with-roles/*" ,
41+ "Condition" : {
42+ "Bool" : {
43+ "aws:SecureTransport" : " false"
44+ }
45+ }
46+ },
47+ {
48+ "Effect" : " Deny" ,
49+ "Principal" : {
50+ "AWS" : " *"
51+ },
52+ "Action" : " s3:PutObject" ,
53+ "Resource" : " arn:aws:s3:::test-bucket-with-roles/*" ,
54+ "Condition" : {
55+ "StringNotEquals" : {
56+ "s3:x-amz-server-side-encryption" : " AES256"
57+ }
58+ }
59+ },
60+ {
61+ "Effect" : " Deny" ,
62+ "Principal" : {
63+ "AWS" : " *"
64+ },
65+ "Action" : " s3:PutObject" ,
66+ "Resource" : " arn:aws:s3:::test-bucket-with-roles/*" ,
67+ "Condition" : {
68+ "Null" : {
69+ "s3:x-amz-server-side-encryption" : " true"
70+ }
71+ }
72+ }
73+ ]
74+ }
75+ },
76+ "Type" : " AWS::S3::BucketPolicy"
77+ },
78+ "TestBucketRestorePolicy" : {
79+ "Properties" : {
80+ "Description" : " Grants read access permissions to test-bucket-with-roles bucket" ,
81+ "ManagedPolicyName" : " TestBucketRestorePolicy" ,
82+ "PolicyDocument" : {
83+ "Version" : " 2012-10-17" ,
84+ "Statement" : [
85+ {
86+ "Effect" : " Allow" ,
87+ "Action" : [
88+ " s3:GetObject"
89+ ],
90+ "Resource" : " arn:aws:s3:::test-bucket-with-roles/*"
91+ },
92+ {
93+ "Effect" : " Allow" ,
94+ "Action" : [
95+ " s3:ListBucket"
96+ ],
97+ "Resource" : " arn:aws:s3:::test-bucket-with-roles"
98+ }
99+ ]
100+ },
101+ "Path" : " /test/"
102+ },
103+ "Type" : " AWS::IAM::ManagedPolicy"
104+ },
105+ "TestBucketRestoreRole" : {
106+ "Properties" : {
107+ "RoleName" : " TestBucketRestoreRole" ,
108+ "Description" : " Role with read access to test-bucket-with-roles bucket." ,
109+ "ManagedPolicyArns" : [
110+ {
111+ "Ref" : " TestBucketRestorePolicy"
112+ }
113+ ],
114+ "AssumeRolePolicyDocument" : {
115+ "Version" : " 2012-10-17" ,
116+ "Statement" : [
117+ {
118+ "Effect" : " Allow" ,
119+ "Action" : " sts:AssumeRole" ,
120+ "Principal" : {
121+ "AWS" : [
122+ " arn:aws:iam::123456789:root"
123+ ]
124+ }
125+ }
126+ ]
127+ },
128+ "Tags" : [
129+ {
130+ "Key" : " Name" ,
131+ "Value" : " TestBucketRestoreRole"
132+ }
133+ ],
134+ "Path" : " /test/"
135+ },
136+ "Type" : " AWS::IAM::Role"
137+ },
138+ "TestBucketPushPolicy" : {
139+ "Properties" : {
140+ "Description" : " Grants write access permissions to test-bucket-with-roles bucket" ,
141+ "ManagedPolicyName" : " TestBucketPushPolicy" ,
142+ "PolicyDocument" : {
143+ "Version" : " 2012-10-17" ,
144+ "Statement" : [
145+ {
146+ "Effect" : " Allow" ,
147+ "Action" : [
148+ " s3:PutObject" ,
149+ " s3:DeleteObject"
150+ ],
151+ "Resource" : " arn:aws:s3:::test-bucket-with-roles/*"
152+ }
153+ ]
154+ },
155+ "Path" : " /test/"
156+ },
157+ "Type" : " AWS::IAM::ManagedPolicy"
158+ },
159+ "TestBucketPushRole" : {
160+ "Properties" : {
161+ "RoleName" : " TestBucketPushRole" ,
162+ "Description" : " Role with read and write access to test-bucket-with-roles bucket." ,
163+ "ManagedPolicyArns" : [
164+ {
165+ "Ref" : " TestBucketPushPolicy"
166+ },
167+ {
168+ "Ref" : " TestBucketRestorePolicy"
169+ }
170+ ],
171+ "AssumeRolePolicyDocument" : {
172+ "Version" : " 2012-10-17" ,
173+ "Statement" : [
174+ {
175+ "Effect" : " Allow" ,
176+ "Action" : " sts:AssumeRole" ,
177+ "Principal" : {
178+ "AWS" : [
179+ " arn:aws:iam::987654321:root"
180+ ]
181+ }
182+ }
183+ ]
184+ },
185+ "Tags" : [
186+ {
187+ "Key" : " Name" ,
188+ "Value" : " TestBucketPushRole"
189+ }
190+ ],
191+ "Path" : " /test/"
192+ },
193+ "Type" : " AWS::IAM::Role"
194+ }
195+ }
0 commit comments