-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.yml
66 lines (59 loc) · 1.98 KB
/
init.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
Description: >
Antonella Bernobich Dean
This template deploys an S3 bucket and creates a IAM role to allow
EC2 servers to fetch a file from the S3 bucket.
Parameters:
S3BucketName:
Description: The name of the S3 bucket (MUST BE all lowercase)
Type: String
EnvironmentName:
Description: An environment name used as a prefix to resource names
Type: String
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref S3BucketName
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
S3ReadOnlyForEC2Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
Effect: Allow
Principal:
Service: ec2.amazonaws.com
Action: sts:AssumeRole
S3ReadOnlyForEC2InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref S3ReadOnlyForEC2Role
S3ReadOnlyForEC2RolePolicies:
Type: AWS::IAM::Policy
Properties:
PolicyName: S3ReadOnlyForEC2
PolicyDocument:
Statement:
- Effect: Allow
Action:
- "s3:Get*"
- "s3:List*"
Resource: "*"
Roles:
- !Ref S3ReadOnlyForEC2Role
Outputs:
S3BucketName:
Description: A reference to the S3 bucket
Value: !Ref S3Bucket
Export:
Name: !Sub ${EnvironmentName}-S3BUCKET
S3ReadOnlyInstanceProfile:
Description: The IAM instance profile needed for the EC2 instances
Value: !Ref S3ReadOnlyForEC2InstanceProfile
Export:
Name: !Sub ${EnvironmentName}-INST-PROF