forked from AHinMaine/AWSCloudFormation-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS3Bucket_Lockdown_to_IAM_User.template
75 lines (66 loc) · 2.16 KB
/
S3Bucket_Lockdown_to_IAM_User.template
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
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template S3Bucket_Lockdown_to_IAM_User: Simple test template showing how to create a bucket and an IAM user and lock the bucket down to be accessible by that new user. **WARNING** This template creates an Amazon S3 Bucket. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"Password" : {
"Type" : "String",
"Description" : "IAM user login password",
"NoEcho" : "true",
"MinLength" : "3",
"MaxLength" : "50"
}
},
"Resources" : {
"S3Bucket" : {
"Type" : "AWS::S3::Bucket"
},
"BucketPolicy" : {
"Type" : "AWS::S3::BucketPolicy",
"Properties" : {
"PolicyDocument": {
"Id" : "Give access to user",
"Statement" : [{
"Sid" : "AllAccess",
"Action" : ["s3:*"],
"Effect" : "Allow",
"Resource" : { "Fn::Join" : ["", ["arn:aws:s3:::", {"Ref" : "S3Bucket"} ]]},
"Principal" : { "AWS": {"Fn::GetAtt" : ["S3User", "Arn"]} }
}]
},
"Bucket" : {"Ref" : "S3Bucket"}
}
},
"S3User" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"LoginProfile": {
"Password": { "Ref" : "Password" }
},
"Policies" : [{
"PolicyName" : "S3Access",
"PolicyDocument" : {
"Statement": [{
"Effect" : "Allow",
"Action" : "s3:ListAllMyBuckets",
"Resource" : "*"
},{
"Effect" : "Allow",
"Action" : "s3:*",
"Resource" : { "Fn::Join" : ["", ["arn:aws:s3:::", {"Ref" : "S3Bucket"} , "/*"]]}
}]
}
}]
}
}
},
"Outputs" : {
"IAMUser" : {
"Value" : { "Ref" : "S3User" },
"Description" : "IAM User for customer"
},
"BucketName" : {
"Value" : { "Ref" : "S3Bucket" },
"Description" : "Name of newly created customer S3 bucket"
}
}
}