Advertisement
uopspop

Untitled

Nov 15th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 13.26 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-223f945a
  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.               # ......
  193.               # install cfn-bootstrap for rhel7
  194.               sudo yum install python-setuptools -y;
  195.               sudo mkdir -p /opt/aws/bin;
  196.               sudo wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz;
  197.               sudo easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz;
  198.               # send complete signal to ASG001
  199.               sudo /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ASG001 --region ${AWS::Region}
  200.       AssociatePublicIpAddress: true
  201.       SecurityGroups:
  202.        - !Ref SG001
  203.   ASG001:
  204.     Type: 'AWS::AutoScaling::AutoScalingGroup'
  205.     Properties:
  206.       VPCZoneIdentifier:
  207.        - !Ref Subnet001
  208.       LaunchConfigurationName: !Ref LaunchConfig001
  209.       DesiredCapacity: !Ref ASG001DesiredCapacity
  210.       MinSize: '1'
  211.       MaxSize: '4'
  212.       Tags:
  213.         - PropagateAtLaunch: true
  214.           Key: Name
  215.           Value: !Ref OverallTagName
  216.     CreationPolicy:
  217.       ResourceSignal:
  218.         Count: !Ref ASG001DesiredCapacity
  219.         Timeout: PT30M          
  220. Description: some description for the template
  221. Metadata:
  222.   'AWS::CloudFormation::Designer':
  223.     6c215780-cc5d-4f7c-9029-f833506b0ab6:
  224.       size:
  225.         width: 60
  226.         height: 60
  227.       position:
  228.         x: -130
  229.         'y': 240
  230.       z: 0
  231.       embeds: []
  232.     100906b8-589d-45d3-9633-4eb9e44ddbaf:
  233.       size:
  234.         width: 690
  235.         height: 690
  236.       position:
  237.         x: -10
  238.         'y': 80
  239.       z: 1
  240.       embeds:
  241.        - c93e3089-9729-4403-b730-6737ff99ad2a
  242.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  243.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  244.     c8ac8be7-0b4a-4496-a8d3-1a54e2e42d5a:
  245.       size:
  246.         width: 60
  247.         height: 60
  248.       position:
  249.         x: -130
  250.         'y': 540
  251.       z: 0
  252.       embeds: []
  253.       iscontainedinside:
  254.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  255.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  256.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  257.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  258.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  259.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  260.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  261.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  262.     c93e3089-9729-4403-b730-6737ff99ad2a:
  263.       size:
  264.         width: 240
  265.         height: 240
  266.       position:
  267.         x: 400
  268.         'y': 160
  269.       z: 2
  270.       parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  271.       embeds:
  272.        - 0b13684f-bf67-44c6-a0ce-d788f1544e49
  273.       iscontainedinside:
  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.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  281.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  282.     0b13684f-bf67-44c6-a0ce-d788f1544e49:
  283.       size:
  284.         width: 60
  285.         height: 60
  286.       position:
  287.         x: 520
  288.         'y': 170
  289.       z: 3
  290.       parent: c93e3089-9729-4403-b730-6737ff99ad2a
  291.       embeds: []
  292.       isassociatedwith:
  293.        - 6c215780-cc5d-4f7c-9029-f833506b0ab6
  294.       iscontainedinside:
  295.        - c93e3089-9729-4403-b730-6737ff99ad2a
  296.         - c93e3089-9729-4403-b730-6737ff99ad2a
  297.         - c93e3089-9729-4403-b730-6737ff99ad2a
  298.         - c93e3089-9729-4403-b730-6737ff99ad2a
  299.         - c93e3089-9729-4403-b730-6737ff99ad2a
  300.         - c93e3089-9729-4403-b730-6737ff99ad2a
  301.         - c93e3089-9729-4403-b730-6737ff99ad2a
  302.         - c93e3089-9729-4403-b730-6737ff99ad2a
  303.     cda52d9d-e7bd-468e-91d9-d51ffa33abd1:
  304.       size:
  305.         width: 330
  306.         height: 240
  307.       position:
  308.         x: 40
  309.         'y': 150
  310.       z: 2
  311.       parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  312.       embeds:
  313.        - 1b8e9c00-552b-421b-bbd6-3d8773821d7e
  314.         - 811c3c9c-8e1d-413a-b908-22829b94aa85
  315.       iscontainedinside:
  316.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  317.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  318.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  319.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  320.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  321.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  322.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  323.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  324.     1b8e9c00-552b-421b-bbd6-3d8773821d7e:
  325.       size:
  326.         width: 60
  327.         height: 60
  328.       position:
  329.         x: 70
  330.         'y': 210
  331.       z: 3
  332.       parent: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  333.       embeds: []
  334.       iscontainedinside:
  335.        - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  336.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  337.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  338.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  339.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  340.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  341.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  342.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  343.     811c3c9c-8e1d-413a-b908-22829b94aa85:
  344.       size:
  345.         width: 60
  346.         height: 60
  347.       position:
  348.         x: 190
  349.         'y': 210
  350.       z: 3
  351.       parent: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  352.       embeds: []
  353.       iscontainedinside:
  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.         - cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  362.     80af6f4c-1d4d-4f66-8237-11fbaa5d8061:
  363.       size:
  364.         width: 240
  365.         height: 240
  366.       position:
  367.         x: 40
  368.         'y': 500
  369.       z: 2
  370.       parent: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  371.       embeds:
  372.        - 5467a301-e1f2-4320-93d1-c8c93b84306f
  373.       iscontainedinside:
  374.        - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  375.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  376.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  377.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  378.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  379.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  380.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  381.         - 100906b8-589d-45d3-9633-4eb9e44ddbaf
  382.     8db514ed-7e5f-42db-868e-e430d15b5bb8:
  383.       source:
  384.         id: c93e3089-9729-4403-b730-6737ff99ad2a
  385.       target:
  386.         id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  387.       z: 2
  388.     455b97eb-821c-4699-a909-5fd0b44cabbd:
  389.       source:
  390.         id: cda52d9d-e7bd-468e-91d9-d51ffa33abd1
  391.       target:
  392.         id: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  393.       z: 2
  394.     5467a301-e1f2-4320-93d1-c8c93b84306f:
  395.       size:
  396.         width: 60
  397.         height: 60
  398.       position:
  399.         x: 70
  400.         'y': 560
  401.       z: 3
  402.       parent: 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  403.       embeds: []
  404.       iscontainedinside:
  405.        - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  406.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  407.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  408.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  409.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  410.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  411.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  412.         - 80af6f4c-1d4d-4f66-8237-11fbaa5d8061
  413.     1f2155f4-d323-494e-b157-1e0a8c2f338c:
  414.       size:
  415.         width: 60
  416.         height: 60
  417.       position:
  418.         x: -120
  419.         'y': 140
  420.       z: 0
  421.       embeds: []
  422.     4e13c20d-0335-44e7-a6f4-d8a27ee8642c:
  423.       source:
  424.         id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  425.       target:
  426.         id: 1f2155f4-d323-494e-b157-1e0a8c2f338c
  427.       z: 2
  428.     16e7a5e4-f13b-4591-b6c8-3722c22f229f:
  429.       source:
  430.         id: 100906b8-589d-45d3-9633-4eb9e44ddbaf
  431.       target:
  432.         id: 6c215780-cc5d-4f7c-9029-f833506b0ab6
  433.       z: 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement