cloudmason 0.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/CODEOWNERS +1 -0
- package/.github/workflows/main.yml +27 -27
- package/README.md +373 -25
- package/build.js +20 -20
- package/commands/delete.js +67 -28
- package/commands/helpers/cf.js +181 -117
- package/commands/helpers/common.js +82 -0
- package/commands/helpers/ec2.js +154 -40
- package/commands/helpers/params.js +231 -178
- package/commands/helpers/s3.js +186 -67
- package/commands/helpers/stacks/asg.yaml +420 -224
- package/commands/helpers/stacks/infra.yaml +102 -106
- package/commands/helpers/stacks.js +25 -25
- package/commands/index.html +22 -0
- package/commands/init_org.js +54 -61
- package/commands/inspect.js +40 -0
- package/commands/launch_app.js +80 -57
- package/commands/list_apps.js +21 -21
- package/commands/new_app.js +44 -50
- package/commands/new_instance.js +133 -186
- package/commands/reset_stack.js +27 -27
- package/commands/starter.js +21 -0
- package/commands/starters/asg_node/index.js +62 -0
- package/commands/starters/asg_node/mason.txt +1 -0
- package/commands/starters/asg_node/modules/appConfig.js +131 -0
- package/commands/starters/asg_node/package-lock.json +5877 -0
- package/commands/starters/asg_node/package.json +23 -0
- package/commands/starters/asg_node/public/css/favicon-16x16.png +0 -0
- package/commands/starters/asg_node/public/css/fonts/Lato-Bold.ttf +0 -0
- package/commands/starters/asg_node/public/css/fonts/Lato-Regular.ttf +0 -0
- package/commands/starters/asg_node/public/css/fonts/Montserrat-Var.ttf +0 -0
- package/commands/starters/asg_node/public/css/fonts/OpenSans.ttf +0 -0
- package/commands/starters/asg_node/public/css/fonts/bpmn.woff2 +0 -0
- package/commands/starters/asg_node/public/css/fonts/fonts.css +17 -0
- package/commands/starters/asg_node/public/css/index.css +9 -0
- package/commands/starters/asg_node/public/index.html +15 -0
- package/commands/starters/asg_node/public/js/index.js +5 -0
- package/commands/starters/asg_node/start.sh +4 -0
- package/commands/update_app.js +235 -272
- package/commands/update_stack.js +27 -0
- package/commands/utils.js +32 -32
- package/main.js +262 -220
- package/package.json +1 -28
- package/test.bat +16 -9
- package/commands/delete_app.js +0 -28
- package/commands/helpers/stacks/asg_draft.json +0 -321
|
@@ -1,224 +1,420 @@
|
|
|
1
|
-
AWSTemplateFormatVersion: '2010-09-09'
|
|
2
|
-
Description: ASG Cloudformation Template
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Parameters:
|
|
6
|
-
InstanceRootDomain:
|
|
7
|
-
Type: AWS::Route53::HostedZone::Id
|
|
8
|
-
Description: Hosted Zone
|
|
9
|
-
InstanceDomain:
|
|
10
|
-
Type: String
|
|
11
|
-
Description: Full domain/subdomain name to associate with the ALB
|
|
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
|
-
Type: AWS::
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Type: AWS::
|
|
173
|
-
Properties:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
|
2
|
+
Description: ASG Cloudformation Template
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Parameters:
|
|
6
|
+
InstanceRootDomain:
|
|
7
|
+
Type: AWS::Route53::HostedZone::Id
|
|
8
|
+
Description: Hosted Zone
|
|
9
|
+
InstanceDomain:
|
|
10
|
+
Type: String
|
|
11
|
+
Description: Full domain/subdomain name to associate with the ALB
|
|
12
|
+
AllowedPattern: ^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$
|
|
13
|
+
VpcId:
|
|
14
|
+
Type: AWS::EC2::VPC::Id
|
|
15
|
+
Description: Org VPC
|
|
16
|
+
InstanceSubnets:
|
|
17
|
+
Type: List<AWS::EC2::Subnet::Id>
|
|
18
|
+
Description: Subnets to deploy in
|
|
19
|
+
MaxEc2Instances:
|
|
20
|
+
Type: Number
|
|
21
|
+
Description: Max number of Ec2 instances
|
|
22
|
+
Default: 2
|
|
23
|
+
EC2InstanceType:
|
|
24
|
+
Type: String
|
|
25
|
+
Description: EC2 Instance Type
|
|
26
|
+
Default: t2.small
|
|
27
|
+
AdminEmail:
|
|
28
|
+
Type: String
|
|
29
|
+
Description: Email for the first admin user
|
|
30
|
+
AmiId:
|
|
31
|
+
Type: AWS::EC2::Image::Id
|
|
32
|
+
Description: Max number of Ec2 instances
|
|
33
|
+
AppVersion:
|
|
34
|
+
Type: String
|
|
35
|
+
Description: Major.minor.build
|
|
36
|
+
InstanceEnvironment:
|
|
37
|
+
Type: String
|
|
38
|
+
Description: Instance enviroment (prod,dev). Setting prod will enable advanced security features.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Resources:
|
|
42
|
+
# ACM Domain
|
|
43
|
+
ACMDomainCert:
|
|
44
|
+
Type: 'AWS::CertificateManager::Certificate'
|
|
45
|
+
Properties:
|
|
46
|
+
DomainName: !Ref InstanceDomain
|
|
47
|
+
ValidationMethod: DNS
|
|
48
|
+
DomainValidationOptions:
|
|
49
|
+
- DomainName: !Ref InstanceDomain
|
|
50
|
+
HostedZoneId: !Ref InstanceRootDomain
|
|
51
|
+
# ALB
|
|
52
|
+
AppALB:
|
|
53
|
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
|
54
|
+
Properties:
|
|
55
|
+
Scheme: internet-facing
|
|
56
|
+
Type: application
|
|
57
|
+
IpAddressType: ipv4
|
|
58
|
+
SecurityGroups:
|
|
59
|
+
- !GetAtt AppALBSecurityGroup.GroupId
|
|
60
|
+
Subnets: !Ref InstanceSubnets
|
|
61
|
+
AppALBHTTPSListener:
|
|
62
|
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
|
63
|
+
Properties:
|
|
64
|
+
Certificates:
|
|
65
|
+
- CertificateArn: !Ref ACMDomainCert
|
|
66
|
+
DefaultActions:
|
|
67
|
+
- Type: authenticate-cognito
|
|
68
|
+
Order: 1
|
|
69
|
+
AuthenticateCognitoConfig:
|
|
70
|
+
UserPoolArn: !GetAtt CognitoUserPool.Arn
|
|
71
|
+
UserPoolClientId: !Ref CognitoUserPoolClient
|
|
72
|
+
# UserPoolDomain: !Sub '${CognitoUserPool}.auth.${AWS::Region}.amazoncognito.com'
|
|
73
|
+
# UserPoolDomain: !Ref CognitoUserPoolDomain
|
|
74
|
+
UserPoolDomain: !Ref CognitoUserPoolDomain
|
|
75
|
+
OnUnauthenticatedRequest: "authenticate"
|
|
76
|
+
- Type: forward
|
|
77
|
+
Order: 2
|
|
78
|
+
ForwardConfig:
|
|
79
|
+
TargetGroups:
|
|
80
|
+
- TargetGroupArn: !Ref AppALBTargetGroup
|
|
81
|
+
Weight: 999
|
|
82
|
+
TargetGroupStickinessConfig:
|
|
83
|
+
DurationSeconds: 900
|
|
84
|
+
Enabled: false
|
|
85
|
+
LoadBalancerArn: !Ref AppALB
|
|
86
|
+
Port: 443
|
|
87
|
+
Protocol: HTTPS
|
|
88
|
+
AppALBHTTPRedirectListener:
|
|
89
|
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
|
90
|
+
Properties:
|
|
91
|
+
DefaultActions:
|
|
92
|
+
- RedirectConfig:
|
|
93
|
+
Port: "443"
|
|
94
|
+
Protocol: HTTPS
|
|
95
|
+
StatusCode: HTTP_301
|
|
96
|
+
Type: redirect
|
|
97
|
+
LoadBalancerArn: !Ref AppALB
|
|
98
|
+
Port: 80
|
|
99
|
+
Protocol: HTTP
|
|
100
|
+
AppALBSecurityGroup:
|
|
101
|
+
Type: AWS::EC2::SecurityGroup
|
|
102
|
+
Properties:
|
|
103
|
+
VpcId: !Ref VpcId
|
|
104
|
+
GroupDescription: Allow http to client host
|
|
105
|
+
SecurityGroupIngress:
|
|
106
|
+
- IpProtocol: tcp
|
|
107
|
+
FromPort: 80
|
|
108
|
+
ToPort: 80
|
|
109
|
+
CidrIp: 0.0.0.0/0
|
|
110
|
+
- IpProtocol: tcp
|
|
111
|
+
FromPort: 443
|
|
112
|
+
ToPort: 443
|
|
113
|
+
CidrIp: 0.0.0.0/0
|
|
114
|
+
SecurityGroupEgress:
|
|
115
|
+
- IpProtocol: tcp
|
|
116
|
+
FromPort: 443
|
|
117
|
+
ToPort: 443
|
|
118
|
+
CidrIp: 0.0.0.0/0
|
|
119
|
+
AppALBSecurityGroupEgress:
|
|
120
|
+
Type: AWS::EC2::SecurityGroupEgress
|
|
121
|
+
Properties:
|
|
122
|
+
GroupId: !Ref AppALBSecurityGroup
|
|
123
|
+
Description: Allow ALB to communicate with Ec2
|
|
124
|
+
IpProtocol: tcp
|
|
125
|
+
FromPort: 8080
|
|
126
|
+
ToPort: 8080
|
|
127
|
+
DestinationSecurityGroupId: !Ref AppEc2SecurityGroup
|
|
128
|
+
AppALBRouteRecord:
|
|
129
|
+
Type: AWS::Route53::RecordSet
|
|
130
|
+
Properties:
|
|
131
|
+
Type: A
|
|
132
|
+
Name: !Ref InstanceDomain
|
|
133
|
+
AliasTarget:
|
|
134
|
+
DNSName: !GetAtt AppALB.DNSName
|
|
135
|
+
EvaluateTargetHealth: true
|
|
136
|
+
HostedZoneId: !GetAtt AppALB.CanonicalHostedZoneID
|
|
137
|
+
HostedZoneId: !Ref InstanceRootDomain
|
|
138
|
+
Region: !Ref AWS::Region
|
|
139
|
+
SetIdentifier: !Ref AWS::Region
|
|
140
|
+
# Autoscaling Group
|
|
141
|
+
AppASG:
|
|
142
|
+
Type: AWS::AutoScaling::AutoScalingGroup
|
|
143
|
+
UpdatePolicy:
|
|
144
|
+
AutoScalingReplacingUpdate:
|
|
145
|
+
WillReplace: true
|
|
146
|
+
Properties:
|
|
147
|
+
AvailabilityZones:
|
|
148
|
+
Fn::GetAZs: ""
|
|
149
|
+
DesiredCapacity: '1'
|
|
150
|
+
MinSize: '1'
|
|
151
|
+
MaxSize: !Ref MaxEc2Instances
|
|
152
|
+
TargetGroupARNs:
|
|
153
|
+
- !Ref AppALBTargetGroup
|
|
154
|
+
LaunchTemplate:
|
|
155
|
+
LaunchTemplateId: !Ref AppEc2LaunchTemplate
|
|
156
|
+
Version: !GetAtt AppEc2LaunchTemplate.LatestVersionNumber
|
|
157
|
+
AppALBTargetGroup:
|
|
158
|
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
|
159
|
+
Properties:
|
|
160
|
+
HealthCheckIntervalSeconds: 30
|
|
161
|
+
HealthCheckPath: /
|
|
162
|
+
HealthCheckTimeoutSeconds: 5
|
|
163
|
+
HealthyThresholdCount: 3
|
|
164
|
+
Matcher:
|
|
165
|
+
HttpCode: 200,300,302
|
|
166
|
+
Port: 8080
|
|
167
|
+
Protocol: HTTP
|
|
168
|
+
TargetType: instance
|
|
169
|
+
UnhealthyThresholdCount: 2
|
|
170
|
+
VpcId: !Ref VpcId
|
|
171
|
+
ASGCPUPolicy:
|
|
172
|
+
Type: AWS::AutoScaling::ScalingPolicy
|
|
173
|
+
Properties:
|
|
174
|
+
AutoScalingGroupName: !Ref AppASG
|
|
175
|
+
PolicyType: TargetTrackingScaling
|
|
176
|
+
TargetTrackingConfiguration:
|
|
177
|
+
PredefinedMetricSpecification:
|
|
178
|
+
PredefinedMetricType: ASGAverageCPUUtilization
|
|
179
|
+
TargetValue: '70'
|
|
180
|
+
AppEc2LaunchTemplate:
|
|
181
|
+
Type: AWS::EC2::LaunchTemplate
|
|
182
|
+
Properties:
|
|
183
|
+
LaunchTemplateName: !Sub '${AWS::StackName}_LaunchTemplate'
|
|
184
|
+
LaunchTemplateData:
|
|
185
|
+
IamInstanceProfile:
|
|
186
|
+
Name:
|
|
187
|
+
Ref: AppEc2Profile
|
|
188
|
+
UserData:
|
|
189
|
+
Fn::Base64:
|
|
190
|
+
!Sub |
|
|
191
|
+
#!/bin/bash
|
|
192
|
+
echo "Running user data"
|
|
193
|
+
cd /home/ec2-user/app
|
|
194
|
+
echo "${AWS::Region},${AWS::StackName},${InstanceEnvironment}" > mason.txt
|
|
195
|
+
chmod +x start.sh
|
|
196
|
+
source start.sh
|
|
197
|
+
ImageId: !Ref AmiId
|
|
198
|
+
DisableApiTermination: "true"
|
|
199
|
+
InstanceType: !Ref EC2InstanceType
|
|
200
|
+
SecurityGroupIds:
|
|
201
|
+
- !Ref AppEc2SecurityGroup
|
|
202
|
+
AppEc2SecurityGroup:
|
|
203
|
+
Type: AWS::EC2::SecurityGroup
|
|
204
|
+
Properties:
|
|
205
|
+
VpcId: !Ref VpcId
|
|
206
|
+
GroupDescription: Allow http to client host
|
|
207
|
+
SecurityGroupEgress:
|
|
208
|
+
- IpProtocol: "-1"
|
|
209
|
+
CidrIp: 0.0.0.0/0
|
|
210
|
+
AppEc2SecurityGroupIngress:
|
|
211
|
+
Type: AWS::EC2::SecurityGroupIngress
|
|
212
|
+
Properties:
|
|
213
|
+
GroupId: !Ref AppEc2SecurityGroup
|
|
214
|
+
Description: Allow 8080 from ALB
|
|
215
|
+
IpProtocol: "-1"
|
|
216
|
+
SourceSecurityGroupId: !Ref AppALBSecurityGroup
|
|
217
|
+
# DynamoDB Table
|
|
218
|
+
DynamoDBTable:
|
|
219
|
+
Type: AWS::DynamoDB::Table
|
|
220
|
+
Properties:
|
|
221
|
+
BillingMode: PAY_PER_REQUEST
|
|
222
|
+
AttributeDefinitions:
|
|
223
|
+
- AttributeName: pk
|
|
224
|
+
AttributeType: S
|
|
225
|
+
- AttributeName: sk
|
|
226
|
+
AttributeType: S
|
|
227
|
+
KeySchema:
|
|
228
|
+
- AttributeName: pk
|
|
229
|
+
KeyType: HASH
|
|
230
|
+
- AttributeName: sk
|
|
231
|
+
KeyType: RANGE
|
|
232
|
+
# S3 App Bucket
|
|
233
|
+
AppBucket:
|
|
234
|
+
Type: AWS::S3::Bucket
|
|
235
|
+
Properties:
|
|
236
|
+
# BucketName: !Ref InstanceDomain
|
|
237
|
+
VersioningConfiguration:
|
|
238
|
+
Status: Enabled
|
|
239
|
+
AppBucketPolicy:
|
|
240
|
+
Type: AWS::S3::BucketPolicy
|
|
241
|
+
Properties:
|
|
242
|
+
Bucket: !Ref AppBucket
|
|
243
|
+
PolicyDocument:
|
|
244
|
+
Version: '2012-10-17'
|
|
245
|
+
Statement:
|
|
246
|
+
- Effect: Allow
|
|
247
|
+
Principal:
|
|
248
|
+
AWS:
|
|
249
|
+
- !GetAtt AppEc2Role.Arn
|
|
250
|
+
Action:
|
|
251
|
+
- 's3:GetObject'
|
|
252
|
+
Resource:
|
|
253
|
+
- !Sub arn:aws:s3:::${AppBucket}
|
|
254
|
+
- !Sub arn:aws:s3:::${AppBucket}/*
|
|
255
|
+
# Cognito
|
|
256
|
+
CognitoUserPool:
|
|
257
|
+
Type: AWS::Cognito::UserPool
|
|
258
|
+
Properties:
|
|
259
|
+
AdminCreateUserConfig:
|
|
260
|
+
AllowAdminCreateUserOnly: True
|
|
261
|
+
AutoVerifiedAttributes:
|
|
262
|
+
- email
|
|
263
|
+
EmailConfiguration:
|
|
264
|
+
EmailSendingAccount: COGNITO_DEFAULT
|
|
265
|
+
UsernameAttributes:
|
|
266
|
+
- email
|
|
267
|
+
Policies:
|
|
268
|
+
PasswordPolicy:
|
|
269
|
+
MinimumLength: 8
|
|
270
|
+
RequireLowercase: True
|
|
271
|
+
RequireNumbers: True
|
|
272
|
+
RequireSymbols: True
|
|
273
|
+
RequireUppercase: True
|
|
274
|
+
CognitoUserPoolClient:
|
|
275
|
+
Type: AWS::Cognito::UserPoolClient
|
|
276
|
+
Properties:
|
|
277
|
+
AllowedOAuthFlows:
|
|
278
|
+
- code
|
|
279
|
+
AllowedOAuthScopes:
|
|
280
|
+
- openid
|
|
281
|
+
AllowedOAuthFlowsUserPoolClient: True
|
|
282
|
+
UserPoolId: !Ref CognitoUserPool
|
|
283
|
+
GenerateSecret: true
|
|
284
|
+
CallbackURLs:
|
|
285
|
+
- !Sub 'https://${InstanceDomain}/oauth2/idpresponse'
|
|
286
|
+
SupportedIdentityProviders:
|
|
287
|
+
- COGNITO
|
|
288
|
+
CognitoIdentityPool:
|
|
289
|
+
Type: AWS::Cognito::IdentityPool
|
|
290
|
+
Properties:
|
|
291
|
+
AllowUnauthenticatedIdentities: false
|
|
292
|
+
CognitoIdentityProviders:
|
|
293
|
+
- ClientId: !Ref CognitoUserPoolClient
|
|
294
|
+
ProviderName: !GetAtt CognitoUserPool.ProviderName
|
|
295
|
+
CognitoUserPoolDomain:
|
|
296
|
+
Type: AWS::Cognito::UserPoolDomain
|
|
297
|
+
DependsOn: AppALBRouteRecord
|
|
298
|
+
Properties:
|
|
299
|
+
Domain: !Sub
|
|
300
|
+
- 'auth-${StackId}'
|
|
301
|
+
- StackId: !Select [2, !Split ['/', !Ref AWS::StackId]]
|
|
302
|
+
UserPoolId: !Ref CognitoUserPool
|
|
303
|
+
CognitoUsrAdminGroup:
|
|
304
|
+
Type: AWS::Cognito::UserPoolGroup
|
|
305
|
+
Properties:
|
|
306
|
+
GroupName: user-admin
|
|
307
|
+
UserPoolId: !Ref CognitoUserPool
|
|
308
|
+
Description: "Admin group for managing users and permissions"
|
|
309
|
+
CognitoUserAdmin:
|
|
310
|
+
Type: AWS::Cognito::UserPoolUser
|
|
311
|
+
Properties:
|
|
312
|
+
DesiredDeliveryMediums:
|
|
313
|
+
- EMAIL
|
|
314
|
+
UserPoolId: !Ref CognitoUserPool
|
|
315
|
+
Username: !Ref AdminEmail
|
|
316
|
+
CognitoUserAdminGroupAttachment:
|
|
317
|
+
Type: AWS::Cognito::UserPoolUserToGroupAttachment
|
|
318
|
+
Properties:
|
|
319
|
+
GroupName: !Ref CognitoUsrAdminGroup
|
|
320
|
+
UserPoolId: !Ref CognitoUserPool
|
|
321
|
+
Username: !Ref AdminEmail
|
|
322
|
+
# IAM
|
|
323
|
+
AppEc2Role:
|
|
324
|
+
Type: 'AWS::IAM::Role'
|
|
325
|
+
Properties:
|
|
326
|
+
AssumeRolePolicyDocument:
|
|
327
|
+
Version: "2012-10-17"
|
|
328
|
+
Statement:
|
|
329
|
+
- Effect: Allow
|
|
330
|
+
Principal:
|
|
331
|
+
Service:
|
|
332
|
+
- ec2.amazonaws.com
|
|
333
|
+
Action:
|
|
334
|
+
- 'sts:AssumeRole'
|
|
335
|
+
Path: !Sub '/apps/${AWS::StackName}/'
|
|
336
|
+
Policies:
|
|
337
|
+
- PolicyName: root
|
|
338
|
+
PolicyDocument:
|
|
339
|
+
Version: "2012-10-17"
|
|
340
|
+
Statement:
|
|
341
|
+
- Effect: Allow
|
|
342
|
+
Action: 'ssm:GetParametersByPath'
|
|
343
|
+
Resource: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${AWS::StackName}*'
|
|
344
|
+
# Resource: '*'
|
|
345
|
+
- Effect: Allow
|
|
346
|
+
Action: 'ssm:GetParameters'
|
|
347
|
+
# Resource: '*'
|
|
348
|
+
Resource: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${AWS::StackName}*'
|
|
349
|
+
- Effect: Allow
|
|
350
|
+
Action: 'ssm:GetParameter'
|
|
351
|
+
# Resource: '*'
|
|
352
|
+
Resource: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${AWS::StackName}*'
|
|
353
|
+
- Effect: Allow
|
|
354
|
+
Action:
|
|
355
|
+
- s3:GetObject
|
|
356
|
+
- s3:GetObjectAttributes
|
|
357
|
+
- s3:ListBucket
|
|
358
|
+
- s3:ListBucketVersions
|
|
359
|
+
- s3:PutObject
|
|
360
|
+
- s3:DeleteObject
|
|
361
|
+
- s3:DeleteObjectVersion
|
|
362
|
+
Resource:
|
|
363
|
+
- !Sub arn:aws:s3:::${AppBucket}
|
|
364
|
+
- !Sub arn:aws:s3:::${AppBucket}/*
|
|
365
|
+
- Effect: Allow
|
|
366
|
+
Action:
|
|
367
|
+
- dynamodb:BatchGetItem
|
|
368
|
+
- dynamodb:BatchWriteItem
|
|
369
|
+
- dynamodb:DeleteItem
|
|
370
|
+
- dynamodb:GetItem
|
|
371
|
+
- dynamodb:GetRecords
|
|
372
|
+
- dynamodb:PutItem
|
|
373
|
+
- dynamodb:Query
|
|
374
|
+
- dynamodb:Scan
|
|
375
|
+
- dynamodb:UpdateItem
|
|
376
|
+
Resource:
|
|
377
|
+
- !GetAtt DynamoDBTable.Arn
|
|
378
|
+
AppEc2Profile:
|
|
379
|
+
Type: AWS::IAM::InstanceProfile
|
|
380
|
+
Properties:
|
|
381
|
+
Path: !Sub '/apps/${AWS::StackName}/'
|
|
382
|
+
Roles:
|
|
383
|
+
- !Ref AppEc2Role
|
|
384
|
+
# Params
|
|
385
|
+
ParamRegion:
|
|
386
|
+
Type: 'AWS::SSM::Parameter'
|
|
387
|
+
Properties:
|
|
388
|
+
Name: !Sub '/${AWS::StackName}/region'
|
|
389
|
+
Type: 'String'
|
|
390
|
+
Value: !Sub '${AWS::Region}'
|
|
391
|
+
ParamS3BUcket:
|
|
392
|
+
Type: 'AWS::SSM::Parameter'
|
|
393
|
+
Properties:
|
|
394
|
+
Name: !Sub '/${AWS::StackName}/s3Bucket'
|
|
395
|
+
Type: 'String'
|
|
396
|
+
Value: !Ref AppBucket
|
|
397
|
+
ParamUserPoolId:
|
|
398
|
+
Type: 'AWS::SSM::Parameter'
|
|
399
|
+
Properties:
|
|
400
|
+
Name: !Sub '/${AWS::StackName}/userpoolid'
|
|
401
|
+
Type: 'String'
|
|
402
|
+
Value: !Ref CognitoUserPool
|
|
403
|
+
ParamDDTable:
|
|
404
|
+
Type: 'AWS::SSM::Parameter'
|
|
405
|
+
Properties:
|
|
406
|
+
Name: !Sub '/${AWS::StackName}/ddbtable'
|
|
407
|
+
Type: 'String'
|
|
408
|
+
Value: !Ref DynamoDBTable
|
|
409
|
+
ParamVersion:
|
|
410
|
+
Type: 'AWS::SSM::Parameter'
|
|
411
|
+
Properties:
|
|
412
|
+
Name: !Sub '/${AWS::StackName}/version'
|
|
413
|
+
Type: 'String'
|
|
414
|
+
Value: !Ref AppVersion
|
|
415
|
+
ParamEnvironment:
|
|
416
|
+
Type: 'AWS::SSM::Parameter'
|
|
417
|
+
Properties:
|
|
418
|
+
Name: !Sub '/${AWS::StackName}/env'
|
|
419
|
+
Type: 'String'
|
|
420
|
+
Value: !Ref InstanceEnvironment
|