cloudmason 0.0.1 → 1.0.1

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.
Files changed (46) hide show
  1. package/.github/workflows/CODEOWNERS +1 -0
  2. package/.github/workflows/main.yml +27 -27
  3. package/README.md +377 -25
  4. package/build.js +20 -20
  5. package/commands/delete.js +67 -28
  6. package/commands/helpers/cf.js +181 -117
  7. package/commands/helpers/common.js +82 -0
  8. package/commands/helpers/ec2.js +154 -40
  9. package/commands/helpers/params.js +231 -178
  10. package/commands/helpers/s3.js +186 -67
  11. package/commands/helpers/stacks/asg.yaml +420 -224
  12. package/commands/helpers/stacks/infra.yaml +102 -106
  13. package/commands/helpers/stacks.js +25 -25
  14. package/commands/index.html +22 -0
  15. package/commands/init_org.js +54 -61
  16. package/commands/inspect.js +40 -0
  17. package/commands/launch_app.js +80 -57
  18. package/commands/list_apps.js +21 -21
  19. package/commands/new_app.js +44 -50
  20. package/commands/new_instance.js +133 -186
  21. package/commands/reset_stack.js +27 -27
  22. package/commands/starter.js +21 -0
  23. package/commands/starters/asg_node/index.js +62 -0
  24. package/commands/starters/asg_node/mason.txt +1 -0
  25. package/commands/starters/asg_node/modules/appConfig.js +131 -0
  26. package/commands/starters/asg_node/package-lock.json +5877 -0
  27. package/commands/starters/asg_node/package.json +23 -0
  28. package/commands/starters/asg_node/public/css/favicon-16x16.png +0 -0
  29. package/commands/starters/asg_node/public/css/fonts/Lato-Bold.ttf +0 -0
  30. package/commands/starters/asg_node/public/css/fonts/Lato-Regular.ttf +0 -0
  31. package/commands/starters/asg_node/public/css/fonts/Montserrat-Var.ttf +0 -0
  32. package/commands/starters/asg_node/public/css/fonts/OpenSans.ttf +0 -0
  33. package/commands/starters/asg_node/public/css/fonts/bpmn.woff2 +0 -0
  34. package/commands/starters/asg_node/public/css/fonts/fonts.css +17 -0
  35. package/commands/starters/asg_node/public/css/index.css +9 -0
  36. package/commands/starters/asg_node/public/index.html +15 -0
  37. package/commands/starters/asg_node/public/js/index.js +5 -0
  38. package/commands/starters/asg_node/start.sh +4 -0
  39. package/commands/update_app.js +235 -272
  40. package/commands/update_stack.js +27 -0
  41. package/commands/utils.js +32 -32
  42. package/main.js +262 -220
  43. package/package.json +1 -28
  44. package/test.bat +16 -9
  45. package/commands/delete_app.js +0 -28
  46. 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
- ACMDomainCert:
13
- Type: String
14
- Description: ARN of AWS ACM Certificate
15
- VpcId:
16
- Type: AWS::EC2::VPC::Id
17
- Description: Org VPC
18
- InstanceSubnets:
19
- Type: List<AWS::EC2::Subnet::Id>
20
- Description: Subnets to deploy in
21
- MaxEc2Instances:
22
- Type: Number
23
- Description: Max number of Ec2 instances
24
- AmiId:
25
- Type: AWS::EC2::Image::Id
26
- Description: Max number of Ec2 instances
27
-
28
-
29
- Resources:
30
- # ALB
31
- AppALB:
32
- Type: AWS::ElasticLoadBalancingV2::LoadBalancer
33
- Properties:
34
- Scheme: internet-facing
35
- Type: application
36
- IpAddressType: ipv4
37
- SecurityGroups:
38
- - !GetAtt AppALBSecurityGroup.GroupId
39
- Subnets: !Ref InstanceSubnets
40
- AppALBHTTPSListener:
41
- Type: AWS::ElasticLoadBalancingV2::Listener
42
- Properties:
43
- Certificates:
44
- - CertificateArn: !Ref ACMDomainCert
45
- DefaultActions:
46
- - Type: forward
47
- ForwardConfig:
48
- TargetGroups:
49
- - TargetGroupArn: !Ref AppALBTargetGroup
50
- Weight: 999
51
- TargetGroupStickinessConfig:
52
- DurationSeconds: 900
53
- Enabled: false
54
- LoadBalancerArn: !Ref AppALB
55
- Port: 443
56
- Protocol: HTTPS
57
- AppALBHTTPRedirectListener:
58
- Type: AWS::ElasticLoadBalancingV2::Listener
59
- Properties:
60
- DefaultActions:
61
- - RedirectConfig:
62
- Port: "443"
63
- Protocol: HTTPS
64
- StatusCode: HTTP_301
65
- Type: redirect
66
- LoadBalancerArn: !Ref AppALB
67
- Port: 80
68
- Protocol: HTTP
69
- AppALBSecurityGroup:
70
- Type: AWS::EC2::SecurityGroup
71
- Properties:
72
- VpcId: !Ref VpcId
73
- GroupDescription: Allow http to client host
74
- SecurityGroupIngress:
75
- - IpProtocol: tcp
76
- FromPort: 80
77
- ToPort: 80
78
- CidrIp: 0.0.0.0/0
79
- - IpProtocol: tcp
80
- FromPort: 443
81
- ToPort: 443
82
- CidrIp: 0.0.0.0/0
83
- AppALBSecurityGroupEgress:
84
- Type: AWS::EC2::SecurityGroupEgress
85
- Properties:
86
- GroupId: !Ref AppALBSecurityGroup
87
- Description: Allow ALB to communicate with Ec2
88
- IpProtocol: tcp
89
- FromPort: 8080
90
- ToPort: 8080
91
- DestinationSecurityGroupId: !Ref AppEc2SecurityGroup
92
- AppALBRouteRecord:
93
- Type: AWS::Route53::RecordSet
94
- Properties:
95
- Type: A
96
- Name: !Ref InstanceDomain
97
- AliasTarget:
98
- DNSName: !GetAtt AppALB.DNSName
99
- EvaluateTargetHealth: true
100
- HostedZoneId: !GetAtt AppALB.CanonicalHostedZoneID
101
- HostedZoneId: !Ref InstanceRootDomain
102
- Region: !Ref AWS::Region
103
- SetIdentifier: !Ref AWS::Region
104
- # Autoscaling Group
105
- AppASG:
106
- Type: AWS::AutoScaling::AutoScalingGroup
107
- Properties:
108
- AvailabilityZones:
109
- Fn::GetAZs: ""
110
- DesiredCapacity: '1'
111
- MinSize: '1'
112
- MaxSize: !Ref MaxEc2Instances
113
- TargetGroupARNs:
114
- - !Ref AppALBTargetGroup
115
- LaunchTemplate:
116
- LaunchTemplateId: !Ref AppEc2LaunchTemplate
117
- Version: !GetAtt AppEc2LaunchTemplate.LatestVersionNumber
118
- AppALBTargetGroup:
119
- Type: AWS::ElasticLoadBalancingV2::TargetGroup
120
- Properties:
121
- HealthCheckIntervalSeconds: 30
122
- HealthCheckPath: /
123
- HealthCheckTimeoutSeconds: 5
124
- HealthyThresholdCount: 3
125
- Matcher:
126
- HttpCode: 200,300,302
127
- Port: 8080
128
- Protocol: HTTP
129
- TargetType: instance
130
- UnhealthyThresholdCount: 2
131
- VpcId: !Ref VpcId
132
- ASGCPUPolicy:
133
- Type: AWS::AutoScaling::ScalingPolicy
134
- Properties:
135
- AutoScalingGroupName: !Ref AppASG
136
- PolicyType: TargetTrackingScaling
137
- TargetTrackingConfiguration:
138
- PredefinedMetricSpecification:
139
- PredefinedMetricType: ASGAverageCPUUtilization
140
- TargetValue: '70'
141
- AppEc2LaunchTemplate:
142
- Type: AWS::EC2::LaunchTemplate
143
- Properties:
144
- LaunchTemplateName: !Sub '${AWS::StackName}_LaunchTemplate'
145
- LaunchTemplateData:
146
- IamInstanceProfile:
147
- Name:
148
- Ref: AppEc2Profile
149
- UserData: {{user_data}}
150
- ImageId: !Ref AmiId
151
- DisableApiTermination: "true"
152
- InstanceType: t2.small
153
- SecurityGroupIds:
154
- - !Ref AppEc2SecurityGroup
155
- AppEc2SecurityGroup:
156
- Type: AWS::EC2::SecurityGroup
157
- Properties:
158
- VpcId: !Ref VpcId
159
- GroupDescription: Allow http to client host
160
- SecurityGroupEgress:
161
- - IpProtocol: "-1"
162
- CidrIp: 0.0.0.0/0
163
- AppEc2SecurityGroupIngress:
164
- Type: AWS::EC2::SecurityGroupIngress
165
- Properties:
166
- GroupId: !Ref AppEc2SecurityGroup
167
- Description: Allow 8080 from ALB
168
- IpProtocol: "-1"
169
- SourceSecurityGroupId: !Ref AppALBSecurityGroup
170
- # S3 App Bucket
171
- AppBucket:
172
- Type: AWS::S3::Bucket
173
- Properties:
174
- BucketName: !Ref InstanceDomain
175
- VersioningConfiguration:
176
- Status: Enabled
177
- AppBucketPolicy:
178
- Type: AWS::S3::BucketPolicy
179
- Properties:
180
- Bucket: !Ref AppBucket
181
- PolicyDocument:
182
- Version: '2012-10-17'
183
- Statement:
184
- - Effect: Allow
185
- Principal:
186
- AWS:
187
- - !GetAtt AppEc2Role.Arn
188
- Action:
189
- - 's3:GetObject'
190
- Resource:
191
- - !Sub arn:aws:s3:::${AppBucket}
192
- - !Sub arn:aws:s3:::${AppBucket}/*
193
- # IAM
194
- AppEc2Role:
195
- Type: 'AWS::IAM::Role'
196
- Properties:
197
- AssumeRolePolicyDocument:
198
- Version: "2012-10-17"
199
- Statement:
200
- - Effect: Allow
201
- Principal:
202
- Service:
203
- - ec2.amazonaws.com
204
- Action:
205
- - 'sts:AssumeRole'
206
- Path: !Sub '/apps/${AWS::StackName}/'
207
- Policies:
208
- - PolicyName: root
209
- PolicyDocument:
210
- Version: "2012-10-17"
211
- Statement:
212
- - Effect: Allow
213
- Action:
214
- - s3:GetObject
215
- - s3:ListBucket
216
- Resource:
217
- - !Sub arn:aws:s3:::${AppBucket}
218
- - !Sub arn:aws:s3:::${AppBucket}/*
219
- AppEc2Profile:
220
- Type: AWS::IAM::InstanceProfile
221
- Properties:
222
- Path: !Sub '/apps/${AWS::StackName}/'
223
- Roles:
224
- - !Ref AppEc2Role
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