uopspop

Untitled

Dec 26th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 14.36 KB | None | 0 0
  1. AWSTemplateFormatVersion: 2010-09-09
  2. Parameters:
  3.   KeyPairName:
  4.     Description:
  5.      You must have your public key on your aws - ec2 - network & security - key
  6.       pairs section
  7.     Type: String
  8.   OverallTagName:
  9.     Type: String
  10.     Default: st-formation
  11.     Description: The tag name for all resources created under this template
  12.   ASG001DesiredCapacity:
  13.     Type: String
  14.     Default: 1
  15.     Description: AutoScalingGroup Initial Desired Capacity
  16. Resources:
  17.   VPC001:
  18.     Type: 'AWS::EC2::VPC'
  19.     Properties:
  20.       CidrBlock: 10.99.0.0/16
  21.       InstanceTenancy: default
  22.       EnableDnsSupport: 'true'
  23.       EnableDnsHostnames: 'false'
  24.       Tags:
  25.         - Key: Name
  26.           Value: !Ref OverallTagName
  27.     Metadata:
  28.       'AWS::CloudFormation::Designer':
  29.         id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  30.   Subnet001:
  31.     Type: 'AWS::EC2::Subnet'
  32.     Properties:
  33.       CidrBlock: 10.99.0.0/24
  34.       AvailabilityZone: us-west-2b
  35.       VpcId: !Ref VPC001
  36.       Tags:
  37.         - Key: Name
  38.           Value: !Ref OverallTagName
  39.     Metadata:
  40.       'AWS::CloudFormation::Designer':
  41.         id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  42.   IGW001:
  43.     Type: 'AWS::EC2::InternetGateway'
  44.     Properties:
  45.       Tags:
  46.         - Key: Name
  47.           Value: !Ref OverallTagName
  48.     Metadata:
  49.       'AWS::CloudFormation::Designer':
  50.         id: 6c215780-cc5d-4f7c-9029-f833506b0ab6
  51.   NACL001:
  52.     Type: 'AWS::EC2::NetworkAcl'
  53.     Properties:
  54.       VpcId: !Ref VPC001
  55.       Tags:
  56.         - Key: Name
  57.           Value: !Ref OverallTagName
  58.     Metadata:
  59.       'AWS::CloudFormation::Designer':
  60.         id: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  61.   RouteTable001:
  62.     Type: 'AWS::EC2::RouteTable'
  63.     Properties:
  64.       VpcId: !Ref VPC001
  65.       Tags:
  66.         - Key: Name
  67.           Value: !Ref OverallTagName
  68.     Metadata:
  69.       'AWS::CloudFormation::Designer':
  70.         id: c93e3089-9729-4403-b730-6737ff99ad2a
  71.   SG001:
  72.     Type: 'AWS::EC2::SecurityGroup'
  73.     Properties:
  74.       GroupDescription: 'launch-wizard-37 created 2018-04-17T19:55:21.240+08:00'
  75.       VpcId: !Ref VPC001
  76.       Tags:
  77.         - Key: Name
  78.           Value: !Ref OverallTagName
  79.     Metadata:
  80.       'AWS::CloudFormation::Designer':
  81.         id: c8ac8be7-0b4a-4496-a8d3-1a54e2e42d5a
  82.   NaclEgressRule001:
  83.     Type: 'AWS::EC2::NetworkAclEntry'
  84.     Properties:
  85.       CidrBlock: 0.0.0.0/0
  86.       Egress: 'true'
  87.       Protocol: '-1'
  88.       RuleAction: allow
  89.       RuleNumber: '100'
  90.       NetworkAclId: !Ref NACL001
  91.     Metadata:
  92.       'AWS::CloudFormation::Designer':
  93.         id: 811c3c9c-8e1d-413a-b908-22829b94aa85
  94.   NaclIngressRule001:
  95.     Type: 'AWS::EC2::NetworkAclEntry'
  96.     Properties:
  97.       CidrBlock: 0.0.0.0/0
  98.       Protocol: '-1'
  99.       RuleAction: allow
  100.       RuleNumber: '101'
  101.       NetworkAclId: !Ref NACL001
  102.     Metadata:
  103.       'AWS::CloudFormation::Designer':
  104.         id: 1b8e9c00-552b-421b-bbd6-3d8773821d7e
  105.   SubnetNaclAssoc001:
  106.     Type: 'AWS::EC2::SubnetNetworkAclAssociation'
  107.     Properties:
  108.       NetworkAclId: !Ref NACL001
  109.       SubnetId: !Ref Subnet001
  110.     Metadata:
  111.       'AWS::CloudFormation::Designer':
  112.         id: 455b97eb-821c-4699-a909-5fd0b44cabbd
  113.   RouteRuleToTheInternet:
  114.     Type: 'AWS::EC2::Route'
  115.     Properties:
  116.       DestinationCidrBlock: 0.0.0.0/0
  117.       RouteTableId: !Ref RouteTable001
  118.       GatewayId: !Ref IGW001
  119.     Metadata:
  120.       'AWS::CloudFormation::Designer':
  121.         id: 0b13684f-bf67-44c6-a0ce-d788f1544e49
  122.   SubnetRouteTableAssoc001:
  123.     Type: 'AWS::EC2::SubnetRouteTableAssociation'
  124.     Properties:
  125.       RouteTableId: !Ref RouteTable001
  126.       SubnetId: !Ref Subnet001
  127.     Metadata:
  128.       'AWS::CloudFormation::Designer':
  129.         id: 8db514ed-7e5f-42db-868e-e430d15b5bb8
  130.   SGIngressRuleSSH:
  131.     Type: 'AWS::EC2::SecurityGroupIngress'
  132.     Properties:
  133.       GroupId: !Ref SG001
  134.       IpProtocol: tcp
  135.       FromPort: '22'
  136.       ToPort: '22'
  137.       CidrIp: 0.0.0.0/0
  138.   SGIngressRuleHTTP:
  139.     Type: 'AWS::EC2::SecurityGroupIngress'
  140.     Properties:
  141.       GroupId: !Ref SG001
  142.       IpProtocol: tcp
  143.       FromPort: '8080'
  144.       ToPort: '8080'
  145.       CidrIp: 0.0.0.0/0
  146.   SGEgressRuleALL:
  147.     Type: 'AWS::EC2::SecurityGroupEgress'
  148.     Properties:
  149.       GroupId: !Ref SG001
  150.       IpProtocol: '-1'
  151.       CidrIp: 0.0.0.0/0
  152.   DHCP001:
  153.     Type: 'AWS::EC2::DHCPOptions'
  154.     Properties:
  155.       DomainName: us-west-2.compute.internal
  156.       DomainNameServers:
  157.        - AmazonProvidedDNS
  158.     Metadata:
  159.       'AWS::CloudFormation::Designer':
  160.         id: 1f2155f4-d323-494e-b157-1e0a8c2f338c
  161.   VpcDhcpAssoc001:
  162.     Type: 'AWS::EC2::VPCDHCPOptionsAssociation'
  163.     Properties:
  164.       DhcpOptionsId: !Ref DHCP001
  165.       VpcId: !Ref VPC001
  166.     Metadata:
  167.       'AWS::CloudFormation::Designer':
  168.         id: 4e13c20d-0335-44e7-a6f4-d8a27ee8642c
  169.   IgwVpcAssoc001:
  170.     Type: 'AWS::EC2::VPCGatewayAttachment'
  171.     Properties:
  172.       VpcId: !Ref VPC001
  173.       InternetGatewayId: !Ref IGW001
  174.     Metadata:
  175.       'AWS::CloudFormation::Designer':
  176.         id: 16e7a5e4-f13b-4591-b6c8-3722c22f229f
  177.   LaunchConfig001:
  178.     Type: 'AWS::AutoScaling::LaunchConfiguration'
  179.     Properties:
  180.       KeyName: !Ref KeyPairName
  181.       ImageId: ami-01e24be29428c15b2
  182.       InstanceType: t2.micro
  183.       UserData:
  184.         Fn::Base64:                               # YAML makes userdata much cleaner
  185.           !Sub |
  186.              #!/bin/bash -ex
  187.               # install basic modules
  188.               sudo yum update -y;
  189.               sudo yum install ruby -y;
  190.               sudo yum install wget -y;
  191.               # do your stuff here
  192.               # docker install
  193.               sudo yum install docker -y;
  194.               sudo service docker start;
  195.               sudo usermod -a -G docker ec2-user;
  196.               sudo docker --version;
  197.               # package manager install
  198.               sudo su - ec2-user -c 'wget https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh';
  199.               sudo su - ec2-user -c 'chmod +x install.sh';
  200.               echo | sudo su - ec2-user -c './install.sh';
  201.               sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew install hello';
  202.               sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew --version';
  203.               # sam cli install
  204.               sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew upgrade';
  205.               sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew update';
  206.               sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew tap aws/tap';
  207.               sudo su - ec2-user -c '/home/linuxbrew/.linuxbrew/bin/brew install aws-sam-cli';
  208.               /home/linuxbrew/.linuxbrew/bin/sam --version;
  209.               # DONE - do your stuff here
  210.               # install cfn-bootstrap for rhel7
  211.               sudo yum install python-setuptools -y;
  212.               sudo mkdir -p /opt/aws/bin;
  213.               sudo wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz;
  214.               sudo easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz;
  215.               # send complete signal to ASG001
  216.               sudo /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ASG001 --region ${AWS::Region}
  217.  
  218.       AssociatePublicIpAddress: true
  219.       SecurityGroups:
  220.        - !Ref SG001
  221.   ASG001:
  222.     Type: 'AWS::AutoScaling::AutoScalingGroup'
  223.     Properties:
  224.       VPCZoneIdentifier:
  225.        - !Ref Subnet001
  226.       LaunchConfigurationName: !Ref LaunchConfig001
  227.       DesiredCapacity: !Ref ASG001DesiredCapacity
  228.       MinSize: '1'
  229.       MaxSize: '4'
  230.       Tags:
  231.         - PropagateAtLaunch: true
  232.           Key: Name
  233.           Value: !Ref OverallTagName
  234.     CreationPolicy:
  235.       ResourceSignal:
  236.         Count: !Ref ASG001DesiredCapacity
  237.         Timeout: PT30M          
  238. Description: some description for the template
  239. Metadata:
  240.   'AWS::CloudFormation::Designer':
  241.     6c215780-cc5d-4f7c-9029-f833506b0ab6:
  242.       size:
  243.         width: 60
  244.         height: 60
  245.       position:
  246.         x: -130
  247.         'y': 240
  248.       z: 0
  249.       embeds: []
  250.     100906b8-589d-45d3-9633-4eb9e44ddbaf:
  251.       size:
  252.         width: 690
  253.         height: 690
  254.       position:
  255.         x: -10
  256.         'y': 80
  257.       z: 1
  258.       embeds:
  259.        - c93e3089-9729-4403-b730-6737ff99ad2a
  260.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  261.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  262.     c8ac8be7-0b4a-4496-a8d3-1a54e2e42d5a:
  263.       size:
  264.         width: 60
  265.         height: 60
  266.       position:
  267.         x: -130
  268.         'y': 540
  269.       z: 0
  270.       embeds: []
  271.       iscontainedinside:
  272.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  273.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  274.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  275.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  276.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  277.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  278.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  279.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  280.     c93e3089-9729-4403-b730-6737ff99ad2a:
  281.       size:
  282.         width: 240
  283.         height: 240
  284.       position:
  285.         x: 400
  286.         'y': 160
  287.       z: 2
  288.       parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  289.       embeds:
  290.        - 0b13684f-bf67-44c6-a0ce-d788f1544e49
  291.       iscontainedinside:
  292.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  293.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  294.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  295.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  296.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  297.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  298.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  299.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  300.     0b13684f-bf67-44c6-a0ce-d788f1544e49:
  301.       size:
  302.         width: 60
  303.         height: 60
  304.       position:
  305.         x: 520
  306.         'y': 170
  307.       z: 3
  308.       parent: c93e3089-9729-4403-b730-6737ff99ad2a
  309.       embeds: []
  310.       isassociatedwith:
  311.        - 6c215780-cc5d-4f7c-9029-f833506b0ab6
  312.       iscontainedinside:
  313.        - c93e3089-9729-4403-b730-6737ff99ad2a
  314.         - c93e3089-9729-4403-b730-6737ff99ad2a
  315.         - c93e3089-9729-4403-b730-6737ff99ad2a
  316.         - c93e3089-9729-4403-b730-6737ff99ad2a
  317.         - c93e3089-9729-4403-b730-6737ff99ad2a
  318.         - c93e3089-9729-4403-b730-6737ff99ad2a
  319.         - c93e3089-9729-4403-b730-6737ff99ad2a
  320.         - c93e3089-9729-4403-b730-6737ff99ad2a
  321.     cda52d9d-e7bd-468e-91d9-d51ffa33abd1:
  322.       size:
  323.         width: 330
  324.         height: 240
  325.       position:
  326.         x: 40
  327.         'y': 150
  328.       z: 2
  329.       parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  330.       embeds:
  331.        - 1b8e9c00-552b-421b-bbd6-3d8773821d7e
  332.         - 811c3c9c-8e1d-413a-b908-22829b94aa85
  333.       iscontainedinside:
  334.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  335.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  336.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  337.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  338.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  339.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  340.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  341.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  342.     1b8e9c00-552b-421b-bbd6-3d8773821d7e:
  343.       size:
  344.         width: 60
  345.         height: 60
  346.       position:
  347.         x: 70
  348.         'y': 210
  349.       z: 3
  350.       parent: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  351.       embeds: []
  352.       iscontainedinside:
  353.        - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  354.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  355.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  356.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  357.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  358.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  359.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  360.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  361.     811c3c9c-8e1d-413a-b908-22829b94aa85:
  362.       size:
  363.         width: 60
  364.         height: 60
  365.       position:
  366.         x: 190
  367.         'y': 210
  368.       z: 3
  369.       parent: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  370.       embeds: []
  371.       iscontainedinside:
  372.        - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  373.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  374.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  375.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  376.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  377.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  378.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  379.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  380.     80af6f4c-1d4d-4f66-8237-11fbaa5d8061:
  381.       size:
  382.         width: 240
  383.         height: 240
  384.       position:
  385.         x: 40
  386.         'y': 500
  387.       z: 2
  388.       parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  389.       embeds:
  390.        - 5467a301-e1f2-4320-93d1-c8c93b84306f
  391.       iscontainedinside:
  392.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  393.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  394.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  395.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  396.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  397.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  398.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  399.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  400.     8db514ed-7e5f-42db-868e-e430d15b5bb8:
  401.       source:
  402.         id: c93e3089-9729-4403-b730-6737ff99ad2a
  403.       target:
  404.         id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  405.       z: 2
  406.     455b97eb-821c-4699-a909-5fd0b44cabbd:
  407.       source:
  408.         id: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  409.       target:
  410.         id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  411.       z: 2
  412.     5467a301-e1f2-4320-93d1-c8c93b84306f:
  413.       size:
  414.         width: 60
  415.         height: 60
  416.       position:
  417.         x: 70
  418.         'y': 560
  419.       z: 3
  420.       parent: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  421.       embeds: []
  422.       iscontainedinside:
  423.        - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  424.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  425.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  426.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  427.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  428.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  429.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  430.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  431.     1f2155f4-d323-494e-b157-1e0a8c2f338c:
  432.       size:
  433.         width: 60
  434.         height: 60
  435.       position:
  436.         x: -120
  437.         'y': 140
  438.       z: 0
  439.       embeds: []
  440.     4e13c20d-0335-44e7-a6f4-d8a27ee8642c:
  441.       source:
  442.         id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  443.       target:
  444.         id: 1f2155f4-d323-494e-b157-1e0a8c2f338c
  445.       z: 2
  446.     16e7a5e4-f13b-4591-b6c8-3722c22f229f:
  447.       source:
  448.         id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  449.       target:
  450.         id: 6c215780-cc5d-4f7c-9029-f833506b0ab6
  451.       z: 2
Add Comment
Please, Sign In to add comment