-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.yml
155 lines (145 loc) · 4.43 KB
/
iam.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'IAM resources'
Parameters:
NameTag:
Type: String
ImagesBucket:
Type: String
Resources:
InstanceProfileRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- 'ec2.amazonaws.com'
Action:
- 'sts:AssumeRole'
Path: '/'
Policies:
- PolicyName: 'CustomPolicy'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:GetEncryptionConfiguration'
- 'ssm:UpdateInstanceInformation'
- 'ssmmessages:CreateControlChannel'
- 'ssmmessages:CreateDataChannel'
- 'ssmmessages:OpenControlChannel'
- 'ssmmessages:OpenDataChannel'
Resource: '*'
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSElasticBeanstalkWebTier'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSElasticBeanstalkWorkerTier'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AmazonEC2RoleforSSM'
InstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: '/'
Roles:
- !Ref 'InstanceProfileRole'
ServiceRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- 'elasticbeanstalk.amazonaws.com'
Action:
- 'sts:AssumeRole'
Condition:
StringEquals:
sts:ExternalId: elasticbeanstalk
Path: '/'
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSElasticBeanstalkService'
User:
Type: 'AWS::IAM::User'
Properties:
Policies:
- PolicyName: 'CustomPolicy'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:Put*'
Resource:
- !Sub 'arn:${AWS::Partition}:s3:::${ImagesBucket}'
- !Sub 'arn:${AWS::Partition}:s3:::${ImagesBucket}/*'
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess'
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess-AWSElasticBeanstalk'
AccessKey:
Type: 'Custom::AccessKey'
DependsOn: User
Version: 1.0
Properties:
UserName: !Ref 'User'
ParameterPath: !Sub '/iam-users/${AWS::StackName}/${User}'
Serial: 1
Status: Active
ReturnSecret: True
ReturnPassword: True
NoEcho: False
ServiceToken: !Sub 'arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:binxio-cfn-secret-provider'
Outputs:
IAMStackName:
Value: !Ref 'AWS::StackName'
Export:
Name: !Sub 'IAMStackName-${AWS::StackName}'
ServiceRole:
Value: !Ref 'ServiceRole'
Export:
Name: !Sub 'ServiceRole-${AWS::StackName}'
ServiceRoleArn:
Value: !GetAtt ServiceRole.Arn
Export:
Name: !Sub 'ServiceRoleArn-${AWS::StackName}'
ServiceRoleId:
Value: !GetAtt ServiceRole.RoleId
Export:
Name: !Sub 'ServiceRoleId-${AWS::StackName}'
InstanceProfileRole:
Value: !Ref 'InstanceProfileRole'
Export:
Name: !Sub 'InstanceProfileRole-${AWS::StackName}'
InstanceProfileRoleArn:
Value: !GetAtt InstanceProfileRole.Arn
Export:
Name: !Sub 'InstanceProfileRoleArn-${AWS::StackName}'
InstanceProfileRoleId:
Value: !GetAtt InstanceProfileRole.RoleId
Export:
Name: !Sub 'InstanceProfileRoleId-${AWS::StackName}'
InstanceProfile:
Value: !Ref 'InstanceProfile'
Export:
Name: !Sub 'InstanceProfile-${AWS::StackName}'
InstanceProfileArn:
Value: !GetAtt InstanceProfile.Arn
Export:
Name: !Sub 'InstanceProfileArn-${AWS::StackName}'
User:
Value: !Ref 'User'
Export:
Name: !Sub 'User-${AWS::StackName}'
AccessKey:
Value: !Ref 'AccessKey'
Export:
Name: !Sub 'AccessKey-${AWS::StackName}'
SecretAccessKey:
Value: !Sub '/iam-users/${AWS::StackName}/${User}/aws_secret_access_key'
Export:
Name: !Sub 'SecretAccessKey-${AWS::StackName}'