-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCFN_template.YAML
More file actions
59 lines (53 loc) · 1.54 KB
/
CFN_template.YAML
File metadata and controls
59 lines (53 loc) · 1.54 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Description: Create an EC2 instance with an S3 bucket and IAM Role for SSM access
Resources:
MyS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: cilbucket
MyEC2InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- Ref: MyEC2Role
MyEC2Role:
Type: AWS::IAM::Role
Properties:
RoleName: SSM-EC2-Role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- ssm:*
- s3:*
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
- arn:aws:iam::aws:policy/AmazonS3FullAccess
Policies:
- PolicyName: SSM-StartSession-Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "ssm:StartSession"
Resource: "arn:aws:ec2:us-east-1:796159111623:instance/04cb4ca688797756f"
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-04cb4ca688797756f
IamInstanceProfile: !Ref MyEC2InstanceProfile
Outputs:
InstanceId:
Description: Instance ID of the created EC2 instance
Value: !Ref MyEC2Instance
S3BucketName:
Description: Name of the created S3 bucket
Value: !Ref MyS3Bucket