Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AWSTemplateFormatVersion: 2010-09-09
- Parameters:
- KeyPairName:
- Description:
- You must have your public key on your aws - ec2 - network & security - key
- pairs section
- Type: String
- OverallTagName:
- Type: String
- Default: st-formation
- Description: The tag name for all resources created under this template
- ASG001DesiredCapacity:
- Type: String
- Default: 1
- Description: AutoScalingGroup Initial Desired Capacity
- Resources:
- VPC001:
- Type: 'AWS::EC2::VPC'
- Properties:
- CidrBlock: 10.99.0.0/16
- InstanceTenancy: default
- EnableDnsSupport: 'true'
- EnableDnsHostnames: 'false'
- Tags:
- - Key: Name
- Value: !Ref OverallTagName
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
- Subnet001:
- Type: 'AWS::EC2::Subnet'
- Properties:
- CidrBlock: 10.99.0.0/24
- AvailabilityZone: us-west-2b
- VpcId: !Ref VPC001
- Tags:
- - Key: Name
- Value: !Ref OverallTagName
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- IGW001:
- Type: 'AWS::EC2::InternetGateway'
- Properties:
- Tags:
- - Key: Name
- Value: !Ref OverallTagName
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 6c215780-cc5d-4f7c-9029-f833506b0ab6
- NACL001:
- Type: 'AWS::EC2::NetworkAcl'
- Properties:
- VpcId: !Ref VPC001
- Tags:
- - Key: Name
- Value: !Ref OverallTagName
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- RouteTable001:
- Type: 'AWS::EC2::RouteTable'
- Properties:
- VpcId: !Ref VPC001
- Tags:
- - Key: Name
- Value: !Ref OverallTagName
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: c93e3089-9729-4403-b730-6737ff99ad2a
- SG001:
- Type: 'AWS::EC2::SecurityGroup'
- Properties:
- GroupDescription: 'launch-wizard-37 created 2018-04-17T19:55:21.240+08:00'
- VpcId: !Ref VPC001
- Tags:
- - Key: Name
- Value: !Ref OverallTagName
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: c8ac8be7-0b4a-4496-a8d3-1a54e2e42d5a
- NaclEgressRule001:
- Type: 'AWS::EC2::NetworkAclEntry'
- Properties:
- CidrBlock: 0.0.0.0/0
- Egress: 'true'
- Protocol: '-1'
- RuleAction: allow
- RuleNumber: '100'
- NetworkAclId: !Ref NACL001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 811c3c9c-8e1d-413a-b908-22829b94aa85
- NaclIngressRule001:
- Type: 'AWS::EC2::NetworkAclEntry'
- Properties:
- CidrBlock: 0.0.0.0/0
- Protocol: '-1'
- RuleAction: allow
- RuleNumber: '101'
- NetworkAclId: !Ref NACL001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 1b8e9c00-552b-421b-bbd6-3d8773821d7e
- SubnetNaclAssoc001:
- Type: 'AWS::EC2::SubnetNetworkAclAssociation'
- Properties:
- NetworkAclId: !Ref NACL001
- SubnetId: !Ref Subnet001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 455b97eb-821c-4699-a909-5fd0b44cabbd
- RouteRuleToTheInternet:
- Type: 'AWS::EC2::Route'
- Properties:
- DestinationCidrBlock: 0.0.0.0/0
- RouteTableId: !Ref RouteTable001
- GatewayId: !Ref IGW001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 0b13684f-bf67-44c6-a0ce-d788f1544e49
- SubnetRouteTableAssoc001:
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- Properties:
- RouteTableId: !Ref RouteTable001
- SubnetId: !Ref Subnet001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 8db514ed-7e5f-42db-868e-e430d15b5bb8
- SGIngressRuleSSH:
- Type: 'AWS::EC2::SecurityGroupIngress'
- Properties:
- GroupId: !Ref SG001
- IpProtocol: tcp
- FromPort: '22'
- ToPort: '22'
- CidrIp: 0.0.0.0/0
- SGIngressRuleHTTP:
- Type: 'AWS::EC2::SecurityGroupIngress'
- Properties:
- GroupId: !Ref SG001
- IpProtocol: tcp
- FromPort: '8080'
- ToPort: '8080'
- CidrIp: 0.0.0.0/0
- SGEgressRuleALL:
- Type: 'AWS::EC2::SecurityGroupEgress'
- Properties:
- GroupId: !Ref SG001
- IpProtocol: '-1'
- CidrIp: 0.0.0.0/0
- DHCP001:
- Type: 'AWS::EC2::DHCPOptions'
- Properties:
- DomainName: us-west-2.compute.internal
- DomainNameServers:
- - AmazonProvidedDNS
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 1f2155f4-d323-494e-b157-1e0a8c2f338c
- VpcDhcpAssoc001:
- Type: 'AWS::EC2::VPCDHCPOptionsAssociation'
- Properties:
- DhcpOptionsId: !Ref DHCP001
- VpcId: !Ref VPC001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 4e13c20d-0335-44e7-a6f4-d8a27ee8642c
- IgwVpcAssoc001:
- Type: 'AWS::EC2::VPCGatewayAttachment'
- Properties:
- VpcId: !Ref VPC001
- InternetGatewayId: !Ref IGW001
- Metadata:
- 'AWS::CloudFormation::Designer':
- id: 16e7a5e4-f13b-4591-b6c8-3722c22f229f
- LaunchConfig001:
- Type: 'AWS::AutoScaling::LaunchConfiguration'
- Properties:
- KeyName: !Ref KeyPairName
- ImageId: ami-01e24be29428c15b2
- InstanceType: t2.micro
- UserData:
- Fn::Base64: # YAML makes userdata much cleaner
- !Sub |
- #!/bin/bash -ex
- # install basic modules
- sudo yum update -y;
- sudo yum install ruby -y;
- sudo yum install wget -y;
- # do your stuff here
- # docker install
- sudo yum install docker -y;
- sudo service docker start;
- sudo usermod -a -G docker ec2-user;
- sudo docker --version;
- # package manager install
- sudo su - ec2-user -c 'wget https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh';
- sudo su - ec2-user -c 'chmod +x install.sh';
- echo | sudo su - ec2-user -c './install.sh';
- sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew install hello';
- sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew --version';
- # sam cli install
- sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew upgrade';
- sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew update';
- sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew tap aws/tap';
- sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew install aws-sam-cli';
- /home/linuxbrew/.linuxbrew/bin/sam --version;
- # DONE - do your stuff here
- # install cfn-bootstrap for rhel7
- sudo yum install python-setuptools -y;
- sudo mkdir -p /opt/aws/bin;
- sudo wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz;
- sudo easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz;
- # send complete signal to ASG001
- sudo /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ASG001 --region ${AWS::Region}
- AssociatePublicIpAddress: true
- SecurityGroups:
- - !Ref SG001
- ASG001:
- Type: 'AWS::AutoScaling::AutoScalingGroup'
- Properties:
- VPCZoneIdentifier:
- - !Ref Subnet001
- LaunchConfigurationName: !Ref LaunchConfig001
- DesiredCapacity: !Ref ASG001DesiredCapacity
- MinSize: '1'
- MaxSize: '4'
- Tags:
- - PropagateAtLaunch: true
- Key: Name
- Value: !Ref OverallTagName
- CreationPolicy:
- ResourceSignal:
- Count: !Ref ASG001DesiredCapacity
- Timeout: PT30M
- Description: some description for the template
- Metadata:
- 'AWS::CloudFormation::Designer':
- 6c215780-cc5d-4f7c-9029-f833506b0ab6:
- size:
- width: 60
- height: 60
- position:
- x: -130
- 'y': 240
- z: 0
- embeds: []
- 100906b8-589d-45d3-9633-4eb9e44ddbaf:
- size:
- width: 690
- height: 690
- position:
- x: -10
- 'y': 80
- z: 1
- embeds:
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- c8ac8be7-0b4a-4496-a8d3-1a54e2e42d5a:
- size:
- width: 60
- height: 60
- position:
- x: -130
- 'y': 540
- z: 0
- embeds: []
- iscontainedinside:
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- c93e3089-9729-4403-b730-6737ff99ad2a:
- size:
- width: 240
- height: 240
- position:
- x: 400
- 'y': 160
- z: 2
- parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
- embeds:
- - 0b13684f-bf67-44c6-a0ce-d788f1544e49
- iscontainedinside:
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- 0b13684f-bf67-44c6-a0ce-d788f1544e49:
- size:
- width: 60
- height: 60
- position:
- x: 520
- 'y': 170
- z: 3
- parent: c93e3089-9729-4403-b730-6737ff99ad2a
- embeds: []
- isassociatedwith:
- - 6c215780-cc5d-4f7c-9029-f833506b0ab6
- iscontainedinside:
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- - c93e3089-9729-4403-b730-6737ff99ad2a
- cda52d9d-e7bd-468e-91d9-d51ffa33abd1:
- size:
- width: 330
- height: 240
- position:
- x: 40
- 'y': 150
- z: 2
- parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
- embeds:
- - 1b8e9c00-552b-421b-bbd6-3d8773821d7e
- - 811c3c9c-8e1d-413a-b908-22829b94aa85
- iscontainedinside:
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- 1b8e9c00-552b-421b-bbd6-3d8773821d7e:
- size:
- width: 60
- height: 60
- position:
- x: 70
- 'y': 210
- z: 3
- parent: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- embeds: []
- iscontainedinside:
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- 811c3c9c-8e1d-413a-b908-22829b94aa85:
- size:
- width: 60
- height: 60
- position:
- x: 190
- 'y': 210
- z: 3
- parent: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- embeds: []
- iscontainedinside:
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- 80af6f4c-1d4d-4f66-8237-11fbaa5d8061:
- size:
- width: 240
- height: 240
- position:
- x: 40
- 'y': 500
- z: 2
- parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
- embeds:
- - 5467a301-e1f2-4320-93d1-c8c93b84306f
- iscontainedinside:
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- - 100906b8-589d-45d3-9633-4eb9e44ddbaf
- 8db514ed-7e5f-42db-868e-e430d15b5bb8:
- source:
- id: c93e3089-9729-4403-b730-6737ff99ad2a
- target:
- id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- z: 2
- 455b97eb-821c-4699-a909-5fd0b44cabbd:
- source:
- id: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
- target:
- id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- z: 2
- 5467a301-e1f2-4320-93d1-c8c93b84306f:
- size:
- width: 60
- height: 60
- position:
- x: 70
- 'y': 560
- z: 3
- parent: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- embeds: []
- iscontainedinside:
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
- 1f2155f4-d323-494e-b157-1e0a8c2f338c:
- size:
- width: 60
- height: 60
- position:
- x: -120
- 'y': 140
- z: 0
- embeds: []
- 4e13c20d-0335-44e7-a6f4-d8a27ee8642c:
- source:
- id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
- target:
- id: 1f2155f4-d323-494e-b157-1e0a8c2f338c
- z: 2
- 16e7a5e4-f13b-4591-b6c8-3722c22f229f:
- source:
- id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
- target:
- id: 6c215780-cc5d-4f7c-9029-f833506b0ab6
- z: 2
Add Comment
Please, Sign In to add comment