-
Notifications
You must be signed in to change notification settings - Fork 12
/
cloud9-cfn.yaml
726 lines (644 loc) · 24.4 KB
/
cloud9-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
721
722
723
724
725
726
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates a Cloud9 IDE for the Fis workshop
Parameters:
CreateVPC:
Description: Create a VPC for Cloud9 instance
Type: String
Default: True
AllowedValues:
- True
- False
EnvironmentName:
Description: An environment name that is prefixed to resource names
Type: String
Default: "fisworkshop"
FisWorkshopC9InstanceType:
Description: Cloud9 instance type
Type: String
Default: t3.medium
AllowedValues:
- t2.micro
- t3.micro
- t3.small
- t3.medium
ConstraintDescription: Must be a valid Cloud9 instance type
FisWorkshopC9EnvType:
Description: Environment type.
Default: self
Type: String
AllowedValues:
- self
- 3rdParty
ConstraintDescription: must specify self or 3rdParty.
WorkshopOwnerArn:
Type: String
Description: The Arn of the Cloud9 Owner to be set if 3rdParty deployment.
Default: "AWS::NoValue"
FisWorkshopC9InstanceVolumeSize:
Type: Number
Description: The Size in GB of the Cloud9 Instance Volume.
Default: 30
Cloud9Name:
Type: String
Description: Name of the Cloud9 instance
Default: "FisWorkshop"
ResourcesPrecreated:
Type: String
Description: Whether lab infrastructure has been pre-provisioned
Default: "false"
AllowedValues:
- "false"
- "true"
UpdateTrigger:
Type: String
Description: Triggers the Cloud9 to update itself
Default: "0"
Cloud9VPC:
Description: If VPC is not created by the template, must provide the VPC Id to deploy the instance
Type: String
Default: AWS::NoValue
Cloud9Subnet:
Description: If VPC is not created by the template, must provide the subnet ID to deploy the instance.
Type: String
Default: AWS::NoValue
VpcCIDR:
Description: Please enter the IP range (CIDR notation) for this VPC
Type: String
Default: 10.10.0.0/16
PublicSubnet1CIDR:
Description: Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone
Type: String
Default: 10.10.10.0/24
PublicSubnet2CIDR:
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
Type: String
Default: 10.10.20.0/24
PrivateSubnet1CIDR:
Description: Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
Type: String
Default: 10.10.30.0/24
PrivateSubnet2CIDR:
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
Type: String
Default: 10.10.40.0/24
Conditions:
Create3rdPartyResources: !Equals [ !Ref FisWorkshopC9EnvType, 3rdParty ]
SkipOwnerArn: !Equals
- !Ref WorkshopOwnerArn
- AWS::NoValue
CreateVPC: !Equals
- !Ref CreateVPC
- True
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Network Configuration"
Parameters:
- CreateVPC
- VpcCIDR
- PublicSubnet1CIDR
- PublicSubnet2CIDR
- PrivateSubnet1CIDR
- PrivateSubnet2CIDR
-
Label:
default: "Cloud9 Configuration"
Parameters:
- Cloud9VPC
- Cloud9Subnet
- C9InstanceType
- C9InstanceVolumeSize
- C9Image
- PatchC9Instance
Resources:
VPC:
Type: AWS::EC2::VPC
Condition: CreateVPC
Metadata:
cfn_nag:
rules_to_suppress:
- id: W60
reason: "No need for Flow logs in this workshop"
cdk_nag:
rules_to_suppress:
- id: AwsSolutions-VPC7
reason: "No need for Flow logs in this workshop"
Properties:
CidrBlock: !Ref VpcCIDR
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Ref EnvironmentName
InternetGateway:
Type: AWS::EC2::InternetGateway
Condition: CreateVPC
Properties:
Tags:
- Key: Name
Value: !Ref EnvironmentName
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Condition: CreateVPC
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
PublicSubnet1:
Type: AWS::EC2::Subnet
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs '' ]
CidrBlock: !Ref PublicSubnet1CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Public Subnet (AZ1)
PublicSubnet2:
Type: AWS::EC2::Subnet
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 1, !GetAZs '' ]
CidrBlock: !Ref PublicSubnet2CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Public Subnet (AZ2)
PrivateSubnet1:
Type: AWS::EC2::Subnet
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs '' ]
CidrBlock: !Ref PrivateSubnet1CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
PrivateSubnet2:
Type: AWS::EC2::Subnet
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 1, !GetAZs '' ]
CidrBlock: !Ref PrivateSubnet2CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Private Subnet (AZ2)
NatGateway1EIP:
Type: AWS::EC2::EIP
Condition: CreateVPC
DependsOn: InternetGatewayAttachment
Properties:
Domain: vpc
NatGateway2EIP:
Type: AWS::EC2::EIP
Condition: CreateVPC
DependsOn: InternetGatewayAttachment
Properties:
Domain: vpc
NatGateway1:
Type: AWS::EC2::NatGateway
Condition: CreateVPC
Properties:
AllocationId: !GetAtt NatGateway1EIP.AllocationId
SubnetId: !Ref PublicSubnet1
NatGateway2:
Type: AWS::EC2::NatGateway
Condition: CreateVPC
Properties:
AllocationId: !GetAtt NatGateway2EIP.AllocationId
SubnetId: !Ref PublicSubnet2
PublicRouteTable:
Type: AWS::EC2::RouteTable
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Public Routes
DefaultPublicRoute:
Type: AWS::EC2::Route
Condition: CreateVPC
DependsOn: InternetGatewayAttachment
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateVPC
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet1
PublicSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateVPC
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet2
PrivateRouteTable1:
Type: AWS::EC2::RouteTable
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Private Routes (AZ1)
DefaultPrivateRoute1:
Type: AWS::EC2::Route
Condition: CreateVPC
Properties:
RouteTableId: !Ref PrivateRouteTable1
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway1
PrivateSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateVPC
Properties:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
PrivateRouteTable2:
Type: AWS::EC2::RouteTable
Condition: CreateVPC
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} Private Routes (AZ2)
DefaultPrivateRoute2:
Type: AWS::EC2::Route
Condition: CreateVPC
Properties:
RouteTableId: !Ref PrivateRouteTable2
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway2
PrivateSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateVPC
Properties:
RouteTableId: !Ref PrivateRouteTable2
SubnetId: !Ref PrivateSubnet2
NoIngressSecurityGroup:
Type: AWS::EC2::SecurityGroup
Metadata:
cfn_nag:
rules_to_suppress:
- id: W5
reason: "Outbound access to the world is needed to download dependencies in C9"
Properties:
GroupDescription: "Security group with no ingress rule"
VpcId: !If [CreateVPC, !Ref VPC, !Ref Cloud9VPC ]
SecurityGroupEgress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
Description: "HTTP Outbound traffic"
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
Description: "HTTPS Outbound traffic"
FisWorkshopC9Role:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${EnvironmentName}-admin"
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
- ssm.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess
- arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
Path: "/"
FisWorkshopC9LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName:
Fn::Join:
- ''
- - FisWorkshopC9LambdaPolicy-
- Ref: AWS::Region
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: arn:aws:logs:*:*:*
- Effect: Allow
Action:
- cloudformation:DescribeStacks
- cloudformation:DescribeStackEvents
- cloudformation:DescribeStackResource
- cloudformation:DescribeStackResources
- ec2:DescribeInstances
- ec2:AssociateIamInstanceProfile
- ec2:ModifyInstanceAttribute
- ec2:ReplaceIamInstanceProfileAssociation
- ec2:DescribeIamInstanceProfileAssociations
- ec2:DescribeVolumes
- ec2:ModifyVolume
- ec2:DescribeVolumesModifications
- ec2:RebootInstances
- iam:ListInstanceProfiles
- iam:PassRole
- ssm:DescribeInstanceInformation
- ssm:SendCommand
- ssm:GetCommandInvocation
Resource: "*"
FisWorkshopC9BootstrapInstanceLambda:
Type: Custom::FisWorkshopC9BootstrapInstanceLambda
DependsOn:
- FisWorkshopC9LambdaExecutionRole
Properties:
ServiceToken:
Fn::GetAtt:
- FisWorkshopC9BootstrapInstanceLambdaFunction
- Arn
REGION:
Ref: AWS::Region
Cloud9Name: !GetAtt FisWorkshopC9Instance.Name
EnvironmentId:
Ref: FisWorkshopC9Instance
LabIdeInstanceProfileName:
Ref: FisWorkshopC9InstanceProfile
LabIdeInstanceProfileArn:
Fn::GetAtt:
- FisWorkshopC9InstanceProfile
- Arn
SsmDocument:
Ref: FisWorkshopC9SSMDocument
UpdateTrigger:
Ref: UpdateTrigger
FisWorkshopC9BootstrapInstanceLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Handler: index.lambda_handler
Role:
Fn::GetAtt:
- FisWorkshopC9LambdaExecutionRole
- Arn
Runtime: python3.12
Environment:
Variables:
DiskSize:
Ref: FisWorkshopC9InstanceVolumeSize
MemorySize: 256
Timeout: '900'
Code:
ZipFile: |
from __future__ import print_function
import boto3
import json
import os
import time
import traceback
import cfnresponse
import logging
logger = logging.getLogger(__name__)
def lambda_handler(event, context):
print(event.values())
print('context: {}'.format(context))
responseData = {}
status = cfnresponse.SUCCESS
if event['RequestType'] == 'Delete':
responseData = {'Success': 'Custom Resource removed'}
cfnresponse.send(event, context, status, responseData, 'CustomResourcePhysicalID')
else:
try:
# Open AWS clients
ec2 = boto3.client('ec2')
ssm = boto3.client('ssm')
# Get the InstanceId of the Cloud9 IDE
instance = ec2.describe_instances(Filters=[{'Name': 'tag:Name','Values': ['aws-cloud9-'+event['ResourceProperties']['Cloud9Name']+'-'+event['ResourceProperties']['EnvironmentId']]}])['Reservations'][0]['Instances'][0]
print('instance: {}'.format(instance))
instance_id = instance['InstanceId']
# Create the IamInstanceProfile request object
iam_instance_profile = {
'Arn': event['ResourceProperties']['LabIdeInstanceProfileArn'],
'Name': event['ResourceProperties']['LabIdeInstanceProfileName']
}
print('Found IAM instance profile: {}'.format(iam_instance_profile))
time.sleep(10)
print('Waiting for the instance to be ready...')
# Wait for Instance to become ready before adding Role
instance_state = instance['State']['Name']
print('Instance is currently in state'.format(instance_state))
while instance_state != 'running':
time.sleep(5)
di = ec2.describe_instances(InstanceIds=[instance_id])
instance_state = di['Reservations'][0]['Instances'][0]['State']['Name']
print('Waiting for instance in state: {}'.format(instance_state))
print('Instance is ready')
reboot = False
associations = ec2.describe_iam_instance_profile_associations(
Filters=[
{
'Name': 'instance-id',
'Values': [instance_id],
},
],
)
if len(associations['IamInstanceProfileAssociations']) > 0:
print('Replacing existing IAM profile...')
for association in associations['IamInstanceProfileAssociations']:
if association['State'] == 'associated':
print("{} is active with state {}".format(association['AssociationId'], association['State']))
if association['IamInstanceProfile']['Arn'] == event['ResourceProperties']['LabIdeInstanceProfileArn']:
print("IAM instance profile is already set")
else:
print("Replacing IAM instance profile")
reboot = True
ec2.replace_iam_instance_profile_association(AssociationId=association['AssociationId'], IamInstanceProfile=iam_instance_profile)
else:
print('Associating IAM profile...')
ec2.associate_iam_instance_profile(IamInstanceProfile=iam_instance_profile, InstanceId=instance_id)
block_volume_id = instance['BlockDeviceMappings'][0]['Ebs']['VolumeId']
block_device = ec2.describe_volumes(VolumeIds=[block_volume_id])['Volumes'][0]
DiskSize = int(os.environ['DiskSize'])
if block_device['Size'] < DiskSize:
reboot = True
print('Modifying block volume: {}'.format(block_volume_id))
ec2.modify_volume(VolumeId=block_volume_id,Size=DiskSize)
time.sleep(10)
for i in range(1, 30):
response = ec2.describe_volumes_modifications(
VolumeIds=[
block_volume_id
]
)
modify_state = response['VolumesModifications'][0]['ModificationState']
if modify_state != 'modifying':
print('Volume has been resized')
break
time.sleep(10)
else:
print('Volume is already sized')
if reboot:
# Reboot is required to avoid weird race condition with IAM role and SSM agent
# It also causes the file system to expand in the OS
print('Rebooting instance')
ec2.reboot_instances(
InstanceIds=[
instance_id,
],
)
time.sleep(60)
print('Waiting for instance to come online in SSM...')
for i in range(1, 60):
response = ssm.describe_instance_information(Filters=[{'Key': 'InstanceIds', 'Values': [instance_id]}])
if len(response["InstanceInformationList"]) == 0:
print('No instances in SSM')
elif len(response["InstanceInformationList"]) > 0 and \
response["InstanceInformationList"][0]["PingStatus"] == "Online" and \
response["InstanceInformationList"][0]["InstanceId"] == instance_id:
print('Instance is online in SSM')
break
time.sleep(10)
ssm_document = event['ResourceProperties']['SsmDocument']
print('Sending SSM command...')
response = ssm.send_command(
InstanceIds=[instance_id],
DocumentName=ssm_document)
command_id = response['Command']['CommandId']
waiter = ssm.get_waiter('command_executed')
waiter.wait(
CommandId=command_id,
InstanceId=instance_id,
WaiterConfig={
'Delay': 10,
'MaxAttempts': 30
}
)
responseData = {'Success': 'Started bootstrapping for instance: '+instance_id}
cfnresponse.send(event, context, status, responseData, 'CustomResourcePhysicalID')
except Exception as e:
status = cfnresponse.FAILED
print(traceback.format_exc())
responseData = {'Error': traceback.format_exc(e)}
finally:
cfnresponse.send(event, context, status, responseData, 'CustomResourcePhysicalID')
FisWorkshopC9SSMDocument:
Type: AWS::SSM::Document
Properties:
DocumentType: Command
DocumentFormat: YAML
Content:
schemaVersion: '2.2'
description: Bootstrap Cloud9 Instance
mainSteps:
- action: aws:runShellScript
name: DependencyInstall
inputs:
runCommand:
- apt update -y
- apt install -y jq gettext bash-completion moreutils
- pip install --upgrade awscli
- sudo -i -u ubuntu bash -l -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash'
- sudo -i -u ubuntu bash -l -c 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"'
- sudo -i -u ubuntu bash -l -c '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
- sudo -i -u ubuntu bash -l -c 'nvm install node --default'
- sudo -i -u ubuntu bash -l -c 'nvm alias default node'
- sudo -i -u ubuntu bash -l -c 'nvm exec node npm install -g aws-cdk --force'
- action: aws:runShellScript
name: KubectlInstall
inputs:
runCommand:
- curl -o kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.31.0/2024-09-12/bin/linux/amd64/kubectl
- chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- echo "source <(kubectl completion bash)" >> /home/ubuntu/.bashrc
- action: aws:runShellScript
name: HelmInstall
inputs:
runCommand:
- curl --location "https://get.helm.sh/helm-v3.13.0-linux-amd64.tar.gz" | tar xz -C /tmp
- sudo mv /tmp/linux-amd64/helm /usr/local/bin/helm
- action: aws:runShellScript
name: eksctlInstall
inputs:
runCommand:
- curl --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
- sudo mv /tmp/eksctl /usr/local/bin
- action: aws:runShellScript
name: cloneRepository
inputs:
runCommand:
- su - ubuntu -c 'mkdir -p ~/environment/workshopfiles && git clone https://github.com/aws-samples/aws-fault-injection-simulator-workshop-v2.git ~/environment/workshopfiles/fis-workshop'
FisWorkshopC9InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: "/"
Roles:
- Ref: FisWorkshopC9Role
FisWorkshopC9Instance:
Type: AWS::Cloud9::EnvironmentEC2
Properties:
Description: AWS Cloud9 instance for Fis Workshop
ImageId: ubuntu-22.04-x86_64
AutomaticStopTimeMinutes: 3600
InstanceType:
Ref: FisWorkshopC9InstanceType
SubnetId: !If [CreateVPC, !Ref PublicSubnet1, !Ref Cloud9Subnet ]
Name: !Ref Cloud9Name
OwnerArn: !If [SkipOwnerArn, !Ref "AWS::NoValue", !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:${WorkshopOwnerArn}"]
Tags:
- Key: SSMBootstrap
Value: Active
Outputs:
Cloud9RoleArn:
Description: The ARN of the IAM role assigned to the Cloud9 instance
Value: !GetAtt FisWorkshopC9Role.Arn
Cloud9InstanceName:
Description: Name of the Cloud9 EC2 instance
Value: !Sub 'aws-cloud9-${FisWorkshopC9Instance.Name}-${FisWorkshopC9Instance}'
Cloud9Url:
Value: !Sub 'https://${AWS::Region}.console.aws.amazon.com/cloud9/ide/${FisWorkshopC9Instance}?region=${AWS::Region}'
VPC:
Description: A reference to the created VPC
Value: !If [ CreateVPC , !Ref VPC, AWS::NoValue ]
PublicSubnets:
Description: A list of the public subnets
Value: !If [ CreateVPC, !Join [ ",", [ !Ref PublicSubnet1, !Ref PublicSubnet2 ]], AWS::NoValue]
PrivateSubnets:
Description: A list of the private subnets
Value: !If [ CreateVPC, !Join [ ",", [ !Ref PrivateSubnet1, !Ref PrivateSubnet2 ]], AWS::NoValue]
PublicSubnet1:
Description: A reference to the public subnet in the 1st Availability Zone
Value: !If [ CreateVPC, !Ref PublicSubnet1, AWS::NoValue ]
PublicSubnet2:
Description: A reference to the public subnet in the 2nd Availability Zone
Value: !If [ CreateVPC, !Ref PublicSubnet2, AWS:NoValue]
PrivateSubnet1:
Description: A reference to the private subnet in the 1st Availability Zone
Value: !If [ CreateVPC, !Ref PrivateSubnet1, AWS:NoValue]
PrivateSubnet2:
Description: A reference to the private subnet in the 2nd Availability Zone
Value: !If [ CreateVPC, !Ref PrivateSubnet2, AWS::NoValue]
NoIngressSecurityGroup:
Description: Security group with no ingress rule
Value: !Ref NoIngressSecurityGroup