forked from widdix/learn-iam-policy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab-environment.yml
134 lines (134 loc) · 3.83 KB
/
lab-environment.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'learn-iam-policy: lab environment'
Parameters:
Subnet:
Description: 'Choose a Subnet for the lab environment.'
Type: 'AWS::EC2::Subnet::Id'
Mappings:
RegionMap:
'ap-south-1':
AMI: 'ami-06bcd1131b2f55803'
'eu-west-3':
AMI: 'ami-051707cdba246187b'
'eu-west-2':
AMI: 'ami-0274e11dced17bb5b'
'eu-west-1':
AMI: 'ami-09693313102a30b2c'
'ap-northeast-2':
AMI: 'ami-0b4fdb56a00adb616'
'ap-northeast-1':
AMI: 'ami-0a2de1c3b415889d2'
'sa-east-1':
AMI: 'ami-0112d42866980b373'
'ca-central-1':
AMI: 'ami-076b4adb3f90cd384'
'ap-southeast-1':
AMI: 'ami-0b84d2c53ad5250c2'
'ap-southeast-2':
AMI: 'ami-08589eca6dcc9b39c'
'eu-central-1':
AMI: 'ami-034fffcc6a0063961'
'us-east-1':
AMI: 'ami-009d6802948d06e52'
'us-east-2':
AMI: 'ami-02e680c4540db351e'
'us-west-1':
AMI: 'ami-011b6930a81cd6aaf'
'us-west-2':
AMI: 'ami-01bbe152bf19d0289'
Resources:
Ec2Instance:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: !FindInMap [RegionMap, !Ref 'AWS::Region', AMI]
InstanceType: 't2.micro'
IamInstanceProfile: !Ref IamInstanceProfile
SubnetId: !Ref Subnet
Tags:
- Key: Name
Value: !Ref 'AWS::StackName'
IamInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Roles:
- !Ref IamRole
IamRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: 'ec2.amazonaws.com'
Action: 'sts:AssumeRole'
Policies:
- PolicyName: 'DO-NOT-CHANGE-LAB-SSM-CONNECTION'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ssm:DescribeAssociation'
- 'ssm:GetDeployablePatchSnapshotForInstance'
- 'ssm:GetDocument'
- 'ssm:GetManifest'
- 'ssm:GetParameters'
- 'ssm:ListAssociations'
- 'ssm:ListInstanceAssociations'
- 'ssm:PutInventory'
- 'ssm:PutComplianceItems'
- 'ssm:PutConfigurePackageResult'
- 'ssm:UpdateAssociationStatus'
- 'ssm:UpdateInstanceAssociationStatus'
- 'ssm:UpdateInstanceInformation'
Resource: '*'
- Effect: Allow
Action:
- 'ssmmessages:CreateControlChannel'
- 'ssmmessages:CreateDataChannel'
- 'ssmmessages:OpenControlChannel'
- 'ssmmessages:OpenDataChannel'
Resource: '*'
- Effect: Allow
Action:
- 'ec2messages:AcknowledgeMessage'
- 'ec2messages:DeleteMessage'
- 'ec2messages:FailMessage'
- 'ec2messages:GetEndpoint'
- 'ec2messages:GetMessages'
- 'ec2messages:SendReply'
Resource: '*'
S3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub 'learn-iam-policy-${AWS::StackName}'
SsmParameterPathAValue1:
Type: 'AWS::SSM::Parameter'
Properties:
Name: !Sub '/${AWS::StackName}/a/1'
Value: 'a1'
Type: 'String'
SsmParameterPathAValue2:
Type: 'AWS::SSM::Parameter'
Properties:
Name: !Sub '/${AWS::StackName}/a/2'
Value: 'a2'
Type: 'String'
SsmParameterPathBValue1:
Type: 'AWS::SSM::Parameter'
Properties:
Name: !Sub '/${AWS::StackName}/b/1'
Value: 'b1'
Type: 'String'
Outputs:
InstanceId:
Description: 'The EC2 instance ID.'
Value: !Ref Ec2Instance
IamRole:
Description: 'The name of the IAM role attached to the EC2 instance.'
Value: !Ref IamRole
S3Bucket:
Description: 'The name of the S3 bucket.'
Value: !Ref S3Bucket