|
@@ -35,65 +35,82 @@ Resources:
|
|
|
- Key: Name
|
|
|
Value: !Ref AWS::StackName
|
|
|
|
|
|
- Instance:
|
|
|
- Type: AWS::EC2::Instance
|
|
|
- CreationPolicy:
|
|
|
- ResourceSignal:
|
|
|
- Timeout: PT5M
|
|
|
- Count: 1
|
|
|
+ InstanceLaunchTemplate:
|
|
|
+ Type: AWS::EC2::LaunchTemplate
|
|
|
Metadata:
|
|
|
AWS::CloudFormation::Init:
|
|
|
config:
|
|
|
packages:
|
|
|
- yum:
|
|
|
+ apt:
|
|
|
wget: []
|
|
|
unzip: []
|
|
|
Properties:
|
|
|
- ImageId: !Ref EC2AMI
|
|
|
- InstanceType: !Ref EC2InstanceType
|
|
|
- KeyName: !Ref KeyName
|
|
|
- SecurityGroupIds:
|
|
|
- - !GetAtt SecurityGroup.GroupId
|
|
|
- UserData:
|
|
|
- Fn::Base64: !Sub |
|
|
|
- #!/bin/bash -xe
|
|
|
-
|
|
|
- # send script output to /tmp so we can debug boot failures
|
|
|
- exec > /tmp/userdata.log 2>&1
|
|
|
-
|
|
|
- # Update all packages
|
|
|
- apt-get update -y
|
|
|
+ LaunchTemplateName: !Sub 'LaunchTemplate_${AWS::StackName}'
|
|
|
+ LaunchTemplateData:
|
|
|
+ ImageId: !Ref EC2AMI
|
|
|
+ InstanceType: !Ref EC2InstanceType
|
|
|
+ KeyName: !Ref KeyName
|
|
|
+ SecurityGroupIds:
|
|
|
+ - !GetAtt SecurityGroup.GroupId
|
|
|
+ BlockDeviceMappings:
|
|
|
+ - DeviceName: /dev/sda1
|
|
|
+ Ebs:
|
|
|
+ VolumeSize: '40'
|
|
|
+ UserData:
|
|
|
+ Fn::Base64: !Sub |
|
|
|
+ #!/bin/bash -xe
|
|
|
|
|
|
- # Get latest cfn scripts;
|
|
|
- # apt-get install -y python3-pip
|
|
|
- apt-get install -y python3-setuptools
|
|
|
- mkdir -p /opt/aws/bin
|
|
|
+ # send script output to /tmp so we can debug boot failures
|
|
|
+ exec > /tmp/userdata.log 2>&1
|
|
|
|
|
|
- # pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
|
|
- wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
|
|
- python3 -m easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-py3-latest.tar.gz
|
|
|
+ # Update all packages
|
|
|
+ apt-get update -y
|
|
|
|
|
|
- ln -s /root/aws-cfn-bootstrap-latest/init/ubuntu/cfn-hup /etc/init.d/cfn-hup
|
|
|
+ # Get latest cfn scripts;
|
|
|
+ # apt-get install -y python3-pip
|
|
|
+ apt-get install -y python3-setuptools
|
|
|
+ mkdir -p /opt/aws/bin
|
|
|
|
|
|
- cd /home/ubuntu/
|
|
|
+ # pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
|
|
+ wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
|
|
+ python3 -m easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-py3-latest.tar.gz
|
|
|
|
|
|
- git clone https://github.com/Joystream/joystream.git
|
|
|
+ # curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
|
|
+ # echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
|
|
+ # apt-get update -y
|
|
|
+ # apt-get install -y yarn
|
|
|
|
|
|
- cd joystream/
|
|
|
+ ln -s /root/aws-cfn-bootstrap-latest/init/ubuntu/cfn-hup /etc/init.d/cfn-hup
|
|
|
|
|
|
- touch setup_complete.txt
|
|
|
-
|
|
|
- echo "Done" > setup_complete.txt
|
|
|
+ Instance:
|
|
|
+ Type: AWS::EC2::Instance
|
|
|
+ Properties:
|
|
|
+ LaunchTemplate:
|
|
|
+ LaunchTemplateId: !Ref InstanceLaunchTemplate
|
|
|
+ Version: !GetAtt InstanceLaunchTemplate.LatestVersionNumber
|
|
|
+ Tags:
|
|
|
+ - Key: Name
|
|
|
+ Value: !Sub '${AWS::StackName}_1'
|
|
|
|
|
|
- # Signal to CloudFormation that the instance is ready
|
|
|
- /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --region ${AWS::Region} --resource Instance
|
|
|
+ Instance2:
|
|
|
+ Type: AWS::EC2::Instance
|
|
|
+ Properties:
|
|
|
+ LaunchTemplate:
|
|
|
+ LaunchTemplateId: !Ref InstanceLaunchTemplate
|
|
|
+ Version: !GetAtt InstanceLaunchTemplate.LatestVersionNumber
|
|
|
Tags:
|
|
|
- Key: Name
|
|
|
- Value: !Ref AWS::StackName
|
|
|
+ Value: !Sub '${AWS::StackName}_2'
|
|
|
|
|
|
Outputs:
|
|
|
- InstanceDNS:
|
|
|
+ PublicIp:
|
|
|
+ Description: The DNS name for the created instance
|
|
|
+ Value: !Sub "${Instance.PublicIp}"
|
|
|
+ Export:
|
|
|
+ Name: !Sub "${AWS::StackName}PublicIp"
|
|
|
+
|
|
|
+ PublicIp2:
|
|
|
Description: The DNS name for the created instance
|
|
|
- Value: !Sub "http://${Instance.PublicDnsName}"
|
|
|
+ Value: !Sub "${Instance2.PublicIp}"
|
|
|
Export:
|
|
|
- Name: InstanceDNS
|
|
|
+ Name: !Sub "${AWS::StackName}PublicIp2"
|