-
Notifications
You must be signed in to change notification settings - Fork 19
/
onboard-account.cfn.yaml
720 lines (677 loc) · 25.7 KB
/
onboard-account.cfn.yaml
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
AWSTemplateFormatVersion: 2010-09-09
Description: This stack provisions resources necessary to use this AWS account with Service Workbench.
Parameters:
EnableFlowLogs:
Type: String
AllowedValues: [true, false]
Description: Enable flow logs on VPCs and Subnets created on this account
Namespace:
Type: String
Description: An environment name that will be prefixed to resource names. Make sure this matches the one declared in your constants file.
MainAccountId:
Type: String
Description: The account id of the main AWS account where the solution is deployed.
ExternalId:
Type: String
Description: A unique ID used to identify this account
VpcCidr:
Description: Please enter the IP range (CIDR notation) for this VPC
Type: String
Default: 10.0.0.0/16
ApiHandlerRoleArn:
Type: String
Description: The arn of apiHandler role
AccountHandlerRoleArn:
Type: String
Description: The arn of main account accountHandler role
StatusHandlerRoleArn:
Type: String
Description: The arn of statusHandler role
# Generous subnet allocation of 8192 addresses
# Range from 10.0.0.0 to 10.0.31.255
PublicSubnetCidr:
Description: Please enter the IP range (CIDR notation) for the public subnet.
Type: String
Default: 10.0.0.0/19
LaunchConstraintRolePrefix:
Description: Role name prefix to use when creating a launch constraint role in the on-boarded account
Type: String
Default: '*'
LaunchConstraintPolicyPrefix:
Description: Customer managed policy name prefix to use when creating a launch constraint role in the on-boarded account
Type: String
Default: '*'
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Shared Configuration
Parameters:
- Namespace
- Label:
default: Account Configuration
Parameters:
- MainAccountId
- ExternalId
- Label:
default: Deployment Configuration
Parameters:
- VpcCidr
- PublicSubnetCidr
Conditions:
enableFlowLogs: !Equals [!Ref EnableFlowLogs, true]
hostNotEqualToMain: !Not [!Equals [!Ref MainAccountId, !Ref AWS::AccountId]]
Mappings:
Solution:
Data:
ID: "SO0231"
Version: "2.0.0"
AppRegistryApplicationName: 'RSWAppReg'
SolutionName: 'Research Service Workbench'
ApplicationType: 'AWS-Solutions'
Resources:
# A role used for launching environments using AWS Service Catalog
# This is the role that code (ApiHandlerLambda) in main account
# assumes before performing any AWS Service Catalog interactions in this account (the on-boarded account)
# for launching environments.
EnvManagementRole:
Type: 'AWS::IAM::Role'
Properties:
RoleName: !Join ['-', [Ref: Namespace, 'env-mgmt']]
Path: '/'
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
AWS:
- !Join [':', ['arn:aws:iam:', Ref: MainAccountId, 'root']]
- !Ref ApiHandlerRoleArn
- !Ref StatusHandlerRoleArn
Action:
- 'sts:AssumeRole'
Condition:
StringEquals:
sts:ExternalId: !Ref ExternalId
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSServiceCatalogAdminFullAccess
Policies:
- PolicyName: eventbus-access
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- events:PutEvents
Resource: !Sub 'arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/default'
- PolicyName: cfn-access
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- cloudformation:GetTemplate
Resource: 'arn:aws:cloudformation:*:*:stack/SC-*/*'
- PolicyName: ssm-access
PolicyDocument:
Statement:
Effect: Allow
Action:
- ssm:PutParameter
- ssm:GetParameter
- ssm:GetParameters
- ssm:DeleteParameter
Resource:
- !Sub 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*/sc-environments/*'
- PolicyName: ssm-doc-execution
PolicyDocument:
Statement:
Effect: Allow
Action:
- ssm:SendCommand
- ssm:StartAutomationExecution
Resource:
- !Sub 'arn:aws:ssm:${AWS::Region}:${MainAccountId}:document/${Namespace}*'
- !Sub 'arn:aws:ssm:${AWS::Region}:${MainAccountId}:automation-definition/${Namespace}*'
- PolicyName: iam-pass-role
PolicyDocument:
Statement:
Effect: Allow
Action:
- iam:PassRole
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/${Namespace}*'
- PolicyName: s3-access
PolicyDocument:
Statement:
Effect: Allow
Action:
- s3:GetObject
Resource:
- 'arn:aws:s3:::cf-templates-*/*'
- PolicyName: servicecatalog-access
PolicyDocument:
Statement:
Effect: Allow
Action:
- servicecatalog:DescribeRecord
Resource:
- '*'
- PolicyName: sagemakerNotebook-access
PolicyDocument:
Statement:
Effect: Allow
Action:
- sagemaker:CreatePresignedNotebookInstanceUrl
- sagemaker:ListNotebookInstances
- sagemaker:StartNotebookInstance
- sagemaker:StopNotebookInstance
- sagemaker:DescribeNotebookInstance
Resource: '*'
# Needed for performing start operation on instances in a given network
- PolicyName: network-access
PolicyDocument:
Statement:
Effect: Allow
Action:
- ec2:DescribeSubnets
- ec2:DescribeVpcs
- ec2:DescribeNetworkInterfaces
- ec2:DescribeSecurityGroups
- ec2:DescribeAvailabilityZones
- ec2:DescribeAccountAttributes
- ec2:CreateTags
- ec2:DeleteTags
- ec2:DescribeInternetGateways
- ec2:DescribeInstances
Resource: '*' # For the actions listed above IAM does not support resource-level permissions and requires all resources to be chosen
- PolicyName: iam-role-access
PolicyDocument:
Statement:
- Effect: Allow
Action:
- iam:CreateRole
- iam:TagRole
- iam:GetRolePolicy
- iam:PutRolePolicy
- iam:DeleteRolePolicy
- iam:ListRolePolicies
- iam:ListAttachedRolePolicies
- iam:UpdateAssumeRolePolicy
- iam:UpdateRoleDescription
- iam:AttachRolePolicy
- iam:DetachRolePolicy
Resource:
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/*presigned-url-sagemaker-notebook-role'
- PolicyName: cloudwatch-access-policy
PolicyDocument:
Statement:
Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${Namespace}-*:*'
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${Namespace}-*:log-stream:*'
# For SSH Key management and connection
- PolicyName: describe-ssh-keys-access-policy
PolicyDocument:
Statement:
Effect: Allow
Action:
- ec2:DescribeKeyPairs
Resource: '*' # IAM does not support resource-level permissions for this action
- PolicyName: ssh-keys-actions-access-policy
PolicyDocument:
Statement:
Effect: Allow
Action:
- ec2:CreateKeyPair
- ec2:DeleteKeyPair
Resource:
- !Sub 'arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:key-pair/sshkey-*' # limits creation to ssh keys following resource naming schema
- PolicyName: ec2-instance-connect-access-policy
PolicyDocument:
Statement:
Effect: Allow
Action:
- ec2-instance-connect:SendSSHPublicKey
Resource:
- !Sub 'arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/*'
- PolicyName: servicequotas-access-policy
PolicyDocument:
Statement:
Effect: Allow
Action:
- servicequotas:GetServiceQuota
Resource:
- !Sub 'arn:aws:servicequotas:${AWS::Region}:${AWS::AccountId}:servicecatalog/L-360CDF2E'
PermissionsBoundary: !Ref EnvMgmtPermissionsBoundary
Metadata:
cfn_nag:
rules_to_suppress:
- id: W11
reason: "For the EC2 and sagemaker actions listed above IAM does not support resource-level permissions and requires all resources to be chosen"
- id: W28
reason: 'TODO: Resource found with an explicit name, this disallows updates that require replacement of this resource'
EnvMgmtPermissionsBoundary:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: Permission boundary for hosting account EnvMgmt role
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- events:PutEvents
Resource: !Sub 'arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/default'
- Effect: Allow
Action:
- s3:*
- cloudformation:*
- sagemaker:*
- ec2:*
- ssm:*
- config:*
- servicecatalog:*
- servicequotas:*
- ec2-instance-connect:*
Resource: '*'
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${Namespace}-*:*'
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${Namespace}-*:log-stream:*'
- Effect: Allow
Action:
- iam:PassRole
Resource: '*'
Condition:
StringEquals:
iam:PassedToService: 'servicecatalog.amazonaws.com'
- Effect: Allow
Action:
- iam:CreateRole
- iam:TagRole
- iam:GetRolePolicy
- iam:PutRolePolicy
- iam:DeleteRolePolicy
- iam:ListRolePolicies
- iam:ListAttachedRolePolicies
- iam:UpdateAssumeRolePolicy
- iam:UpdateRoleDescription
- iam:AttachRolePolicy
- iam:DetachRolePolicy
Resource:
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${LaunchConstraintRolePrefix}*'
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/*presigned-url-sagemaker-notebook-role'
- Effect: Allow
Action:
- iam:CreatePolicy
- iam:GetPolicy
- iam:GetPolicyVersion
- iam:ListPolicyVersions
- iam:DeletePolicy
- iam:DeletePolicyVersion
Resource:
- !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/${LaunchConstraintPolicyPrefix}*'
- Effect: Allow
Action:
- iam:GetGroup
- iam:GetRole
- iam:GetUser
- iam:ListGroups
- iam:ListRoles
- iam:ListUsers
Resource: '*' # These non-mutating IAM actions cover the permissions in managed policy AWSServiceCatalogAdminFullAccess
Metadata:
cfn_nag:
rules_to_suppress:
- id: F40
reason: "There is a condition so that this role can only be passed to Service Catalog per these instructions: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_iam-passrole-service.html"
- id: F5
reason: "This is flagging on a permissions boundary. The role that this boundary is attached too has more strict actions explicitly allowed."
- id: W13
reason: "This is flagging on a permissions boundary. The role that this boundary is attached too has more strict actions explicitly allowed."
PolicyHostingAccountHandler:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: Allows main account to setup hosting account with required resources for launching environments
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- cloudformation:CreateStack
- cloudformation:DeleteStack
- cloudformation:DescribeStacks
- cloudformation:DescribeStackEvents
- cloudformation:GetTemplate
Resource:
- !Sub 'arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/SC-*'
- !Sub 'arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/initial-stack*'
- Effect: Allow
Action:
- cloudformation:GetTemplate
- cloudformation:DescribeStacks
Resource:
- !Sub 'arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/*'
- Effect: Allow
Action:
- sagemaker:ListNotebookInstances
Resource: '*' # For the actions listed above IAM does not support resource-level permissions and requires all resources to be chosen
- Effect: Allow
Action:
- iam:GetRole
- iam:TagRole
- iam:GetRolePolicy
- iam:DeleteRolePolicy
- iam:DeleteRole
- iam:PassRole
- iam:PutRolePolicy
Resource: !Sub 'arn:aws:iam::${AWS::AccountId}:role/analysis-*'
- Effect: Allow
Action:
- iam:CreateRole
- iam:GetRole
- iam:TagRole
- iam:GetRolePolicy
- iam:PutRolePolicy
- iam:DeleteRolePolicy
- iam:ListRolePolicies
- iam:ListAttachedRolePolicies
- iam:UpdateAssumeRolePolicy
- iam:UpdateRoleDescription
- iam:AttachRolePolicy
- iam:DetachRolePolicy
Resource: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${LaunchConstraintRolePrefix}LaunchConstraint*'
- Effect: Allow
Action:
- iam:GetRole
Resource: !GetAtt EnvManagementRole.Arn
- Effect: Allow
Action:
- ce:GetCostAndUsage
Resource: '*' # For the actions listed above IAM does not support resource-level permissions and requires all resources to be chosen
- Effect: Allow
Action:
- budgets:ViewBudget
- budgets:ModifyBudget
Resource: !Sub 'arn:aws:budgets::${AWS::AccountId}:budget/service-workbench-system-generated*'
- Effect: Allow
Action:
- servicecatalog:AcceptPortfolioShare
- servicecatalog:AssociatePrincipalWithPortfolio
Resource: !Sub 'arn:${AWS::Partition}:catalog:${AWS::Region}:${AWS::AccountId}:portfolio/*'
Metadata:
cfn_nag:
rules_to_suppress:
- id: W13
reason: "For the cost explorer and sagemaker actions listed above IAM does not support resource-level permissions and requires all resources to be chosen"
HostingAccountHandlerRole:
Type: 'AWS::IAM::Role'
Properties:
RoleName: !Join ['-', [Ref: Namespace, 'hosting-account-role']] # Confirm the suffix `hosting-account-role` matches with the suffix in RSWStack for AccountHandler
Path: '/'
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
AWS:
- !Join [':', ['arn:aws:iam:', Ref: MainAccountId, 'root']]
- !Ref AccountHandlerRoleArn
Action:
- 'sts:AssumeRole'
Condition:
StringEquals:
sts:ExternalId: !Ref ExternalId
ManagedPolicyArns:
- !Ref PolicyHostingAccountHandler
PermissionsBoundary: !Ref PolicyHostingAccountHandler
Metadata:
cfn_nag:
rules_to_suppress:
- id: W28
reason: 'TODO: Resource found with an explicit name, this disallows updates that require replacement of this resource'
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Sub ${Namespace} vpc
FlowLogVPC:
Type: AWS::EC2::FlowLog
Condition: enableFlowLogs
Properties:
ResourceId: !Ref VPC
ResourceType: VPC
TrafficType: ACCEPT
DeliverLogsPermissionArn: !GetAtt EnvManagementRole.Arn
LogGroupName: VPCLogGroup
LogFormat: '${version} ${vpc-id} ${subnet-id} ${instance-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${tcp-flags} ${type} ${pkt-srcaddr} ${pkt-dstaddr}'
Tags:
- Key: Name
Value: FlowLogForVPC
- Key: Purpose
Value: AcceptTraffic
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub ${Namespace} igw
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs '']
CidrBlock: !Ref PublicSubnetCidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub ${Namespace} public subnet 1
Metadata:
cfn_nag:
rules_to_suppress:
- id: W33
reason: 'TODO:EC2 Subnet should not have MapPublicIpOnLaunch set to true'
FlowLogPublicSubnet:
Type: AWS::EC2::FlowLog
Condition: enableFlowLogs
Properties:
ResourceId: !Ref PublicSubnet
ResourceType: Subnet
TrafficType: ACCEPT
DeliverLogsPermissionArn: !GetAtt EnvManagementRole.Arn
LogGroupName: PublicSubnetLogGroup
LogFormat: '${version} ${vpc-id} ${subnet-id} ${instance-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${tcp-flags} ${type} ${pkt-srcaddr} ${pkt-dstaddr}'
Tags:
- Key: Name
Value: FlowLogForPublicSubnet
- Key: Purpose
Value: AcceptTraffic
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${Namespace} public routes
DefaultPublicRoute:
Type: AWS::EC2::Route
DependsOn: InternetGatewayAttachment
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet
EncryptionKey:
Type: AWS::KMS::Key
Properties:
Description: 'This is the key used to secure resources in this account'
EnableKeyRotation: True
KeyPolicy:
Version: '2012-10-17'
Statement:
- Sid: Allow root access
Effect: 'Allow'
Principal:
AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
Action:
- 'kms:*'
Resource: '*'
- Sid: Allow use of the key by this account
Effect: 'Allow'
Principal:
AWS: '*'
Action:
- 'kms:DescribeKey'
- 'kms:Encrypt'
- 'kms:Decrypt'
- 'kms:ReEncrypt*'
- 'kms:GenerateDataKey'
- 'kms:GenerateDataKeyWithoutPlaintext'
- 'kms:CreateGrant'
- 'kms:RevokeGrant'
Resource: '*'
Condition:
StringEquals:
kms:CallerAccount: !Ref 'AWS::AccountId'
Metadata:
cfn_nag:
rules_to_suppress:
- id: F76
reason: "There is a condition so that the only caller that can use this KMS key is the aws account. The syntax for the Principal element does not provide a way to specify all identities in an AWS account. But you can achieve this effect by combining the condition key kms:CallerAccount with a Principal element that specifies all AWS identities."
EncryptionKeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: !Join ['', ['alias/', Ref: Namespace, '-encryption-key']]
TargetKeyId: !Ref EncryptionKey
StateChangeEventRuleMainRouting:
Condition: hostNotEqualToMain
Type: 'AWS::Events::Rule'
Properties:
Description: Routes environment state changes to the main event bus
EventBusName: !Sub 'arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/default'
State: ENABLED
EventPattern:
account:
- !Ref 'AWS::AccountId'
detail-type:
- anything-but: 'AWS API Call via CloudTrail'
source:
- anything-but:
- 'aws-config'
- 'aws-cloudtrail'
- 'aws-ssm'
- 'aws-tag'
Targets:
- Arn: !Sub 'arn:aws:events:${AWS::Region}:${MainAccountId}:event-bus/default'
Id: 'MainAccountRoutingRule'
RoleArn: !GetAtt
- StateChangeEventBridgeIAMrole
- Arn
StateChangeEventBridgeIAMrole:
Condition: hostNotEqualToMain
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: events.amazonaws.com
Action: 'sts:AssumeRole'
- Effect: Allow
Principal:
Service: sagemaker.amazonaws.com
Action: 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: PutEventsDestinationBus
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'events:Put*'
Resource:
- !Sub 'arn:aws:events:${AWS::Region}:${MainAccountId}:event-bus/default'
Application:
Type: AWS::ServiceCatalogAppRegistry::Application
Properties:
Description: Service Catalog application to track and manage all your resources for the solution Workspaces Cost Optimizer (Replace this with your solution name)
Name: #There is a character limit for this name. Please refer to point # 5 in the above section "Use cases not supported with below setup" for more details.
!Join
- "-"
- - !Ref AWS::StackName
- !FindInMap [Solution, Data, "AppRegistryApplicationName"]
- !Ref AWS::AccountId
Tags: {
'Solutions:SolutionID': !FindInMap [Solution, Data, "ID"],
'Solutions:SolutionVersion': !FindInMap [Solution, Data, "Version"],
'Solutions:SolutionName': !FindInMap [Solution, Data, "SolutionName"],
'Solutions:ApplicationType': !FindInMap [Solution, Data, "ApplicationType"]
}
AppRegistryApplicationStackAssociation:
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
Properties:
Application: !GetAtt Application.Id
Resource:
!Ref AWS::StackId
ResourceType: CFN_STACK
DefaultApplicationAttributes:
Type: AWS::ServiceCatalogAppRegistry::AttributeGroup
Properties:
Name: !Join ['-', [!Ref 'AWS::StackName', !Ref AWS::AccountId]]
Description: Attribute group for solution information.
Attributes:
{ "ApplicationType" : !FindInMap [Solution, Data, "ApplicationType"],
"Version": !FindInMap [Solution, Data, "Version"],
"SolutionID": !FindInMap [Solution, Data, "ID"],
"SolutionName": !FindInMap [Solution, Data, "SolutionName"]
}
AppRegistryApplicationAttributeAssociation:
Type: AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation
Properties:
Application: !GetAtt Application.Id
AttributeGroup: !GetAtt DefaultApplicationAttributes.Id
Outputs:
EnvMgmtRoleArn:
Description: The arn of the hosting account role for environment management using AWS Service Catalog
Value: !GetAtt [EnvManagementRole, Arn]
HostingAccountHandlerRoleArn:
Description: The arn of the hosting account role.
Value: !GetAtt [HostingAccountHandlerRole, Arn]
VPC:
Description: VPC ID
Value: !Ref VPC
VpcSubnet:
Description: A reference to the public subnet in the 1st Availability Zone
Value: !Ref PublicSubnet
EncryptionKeyArn:
Description: KMS Encryption Key Arn
Value: !GetAtt [EncryptionKey, Arn]
PublicRouteTableId:
Description: The public route table assigned to the workspace VPC
Value: !Ref PublicRouteTable
AppRegistryApplicationARN:
Description: App Registry Application ARN
Value: !GetAtt Application.Id