github.com/gorgonia/agogo@v0.1.1/deploy/componenttester/componenttester.yaml (about)

     1  ---
     2  AWSTemplateFormatVersion: '2010-09-09'
     3  Description: ''
     4  Parameters:
     5    KeyName:
     6      Type: AWS::EC2::KeyPair::KeyName
     7      Default: KEYPAIR
     8    ImageId:
     9      Type: String
    10      Default: ami-d38a4ab1
    11      # Default: ami-228a4a40 NON-HVM XENIAL
    12    InstanceType:
    13      Type: String
    14      Default: t2.micro
    15  
    16  Resources:
    17    VPC:
    18      Type: AWS::EC2::VPC
    19      Properties:
    20        CidrBlock: 172.17.0.0/16
    21        InstanceTenancy: default
    22        EnableDnsSupport: true
    23        EnableDnsHostnames: true
    24  
    25    Subnet1:
    26      Type: AWS::EC2::Subnet
    27      Properties:
    28        CidrBlock: 172.17.1.0/24
    29        AvailabilityZone: ap-southeast-2b
    30        VpcId: !Ref VPC
    31  
    32    Subnet2:
    33      Type: AWS::EC2::Subnet
    34      Properties:
    35        CidrBlock: 172.17.2.0/24
    36        AvailabilityZone: ap-southeast-2a
    37        VpcId: !Ref VPC
    38  
    39    SecurityGroup:
    40      Type: AWS::EC2::SecurityGroup
    41      Properties:
    42        GroupDescription: latencytest
    43        VpcId: !Ref VPC
    44  
    45    InboundSGEntry1:
    46      Type: AWS::EC2::SecurityGroupIngress
    47      Properties:
    48        GroupId: !Ref SecurityGroup
    49        IpProtocol: tcp
    50        FromPort: 22
    51        ToPort: 22
    52        CidrIp: 124.169.106.141/24
    53  
    54    InboundSGEntry2:
    55      Type: AWS::EC2::SecurityGroupIngress
    56      Properties:
    57        GroupId: !Ref SecurityGroup
    58        IpProtocol: tcp
    59        FromPort: 22
    60        ToPort: 22
    61        CidrIp: 172.17.1.0/24
    62  
    63    InternetGateway:
    64      Type: AWS::EC2::InternetGateway
    65      Properties:
    66        Tags:
    67        - Key: Name
    68          Value: whatever
    69  
    70    VPCGatewayAttachment:
    71      Type: AWS::EC2::VPCGatewayAttachment
    72      Properties:
    73        VpcId: !Ref VPC
    74        InternetGatewayId: !Ref InternetGateway
    75  
    76    Route1:
    77      Type: AWS::EC2::Route
    78      Properties:
    79        DestinationCidrBlock: 0.0.0.0/0
    80        RouteTableId: !Ref RouteTable
    81        GatewayId: !Ref InternetGateway
    82  
    83    NetworkAcl:
    84      Type: AWS::EC2::NetworkAcl
    85      Properties:
    86        VpcId: !Ref VPC
    87  
    88    ACL1:
    89      Type: AWS::EC2::NetworkAclEntry
    90      Properties:
    91        CidrBlock: 0.0.0.0/0
    92        Egress: 'true'
    93        Protocol: "-1"
    94        RuleAction: allow
    95        RuleNumber: '100'
    96        NetworkAclId: !Ref NetworkAcl
    97  
    98    ACL2:
    99      Type: AWS::EC2::NetworkAclEntry
   100      Properties:
   101        CidrBlock: 0.0.0.0/0
   102        Protocol: "-1"
   103        RuleAction: allow
   104        RuleNumber: '100'
   105        NetworkAclId: !Ref NetworkAcl
   106  
   107    SubnetACL1:
   108      Type: AWS::EC2::SubnetNetworkAclAssociation
   109      Properties:
   110        NetworkAclId: !Ref NetworkAcl
   111        SubnetId: !Ref Subnet1
   112  
   113    SubnetACL2:
   114      Type: AWS::EC2::SubnetNetworkAclAssociation
   115      Properties:
   116        NetworkAclId: !Ref NetworkAcl
   117        SubnetId: !Ref Subnet2
   118  
   119    RouteTable:
   120      Type: AWS::EC2::RouteTable
   121      Properties:
   122        VpcId: !Ref VPC
   123  
   124    SubnetRoute1:
   125      Type: AWS::EC2::SubnetRouteTableAssociation
   126      Properties:
   127        RouteTableId: !Ref RouteTable
   128        SubnetId: !Ref Subnet1
   129  
   130    SubnetRoute2:
   131      Type: AWS::EC2::SubnetRouteTableAssociation
   132      Properties:
   133        RouteTableId: !Ref RouteTable
   134        SubnetId: !Ref Subnet2
   135  
   136    Compute:
   137      Type: AWS::EC2::Instance
   138      Properties:
   139        ImageId: !Ref ImageId
   140        # InstanceType: !Ref InstanceType
   141        InstanceType: INSTANCETYPE
   142        # SecurityGroups:
   143        #   - !Ref SecurityGroup
   144        KeyName: !Ref KeyName
   145        NetworkInterfaces:
   146        - SubnetId: !Ref Subnet1
   147          AssociatePublicIpAddress: 'true'
   148          DeviceIndex: '0'
   149          GroupSet:
   150          - !Ref SecurityGroup
   151        UserData:
   152            Fn::Base64: !Sub |
   153              #!bin/bash -xe
   154              apt-get update
   155              apt-get -y install graphviz gv awscli zip python-setuptools
   156              mkdir aws-cfn-bootstrap-latest
   157              curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1
   158              easy_install aws-cfn-bootstrap-latest
   159  
   160              cd /tmp
   161              wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
   162              tar -xvf go1.10.linux-amd64.tar.gz
   163              mv go /usr/local
   164  
   165              export PATH=$PATH:/usr/local/go/bin
   166              export GOPATH=/home/ubuntu/go
   167              export AWS_ACCESS_KEY_ID=EC2KEY
   168              export AWS_SECRET_ACCESS_KEY=EC2SECRET
   169              export AWS_DEFAULT_REGION=ap-southeast-2
   170              export RUNDATE=`date +%Y-%m-%d-%Ih%Mm`
   171  
   172              cat << EOF > /tmp/deploy.sh
   173              #!/bin/bash -xe
   174              go get gorgonia.org/gorgonia
   175              go get gorgonia.org/tensor
   176              go get gorgonia.org/dawson
   177              go get github.com/gogo/protobuf/gogoproto
   178              go get github.com/golang/protobuf/proto
   179              go get github.com/google/flatbuffers/go
   180              cd /home/ubuntu
   181              git clone https://GITUSER:GITPASS@github.com/chewxy/agogo.git
   182              cd /home/ubuntu/agogo
   183              cd $GOPATH/src/gorgonia.org/gorgonia
   184              git checkout GORGBRANCH
   185              git pull
   186              cd $GOPATH/src/gorgonia.org/tensor
   187              git checkout TENSORBRANCH
   188              git pull
   189              cd /home/ubuntu/agogo/COMPONENT
   190              go test -tags=avx -run=. -v -trace=test-trace-COMPONENT-INSTANCETYPE-$RUNDATE.out | tee stdout-trace-COMPONENT-INSTANCETYPE-$RUNDATE
   191              go test -run=. -v -cpuprofile=test-cpu-COMPONENT-INSTANCETYPE-$RUNDATE.prof | tee stdout-cpuprofile-COMPONENT-INSTANCETYPE-$RUNDATE
   192              zip test-COMPONENT-INSTANCETYPE-$RUNDATE.zip test-* stdout-*
   193              EOF
   194  
   195              chmod u+x /tmp/deploy.sh
   196  
   197              if /tmp/deploy.sh >> /tmp/deploy-$RUNDATE.out; then
   198                state=0
   199                cd /home/ubuntu/agogo/COMPONENT
   200                aws s3 cp test-COMPONENT-INSTANCETYPE-$RUNDATE.zip s3://agogo-testing/
   201                aws s3 cp /tmp/deploy-$RUNDATE.out s3://agogo-testing/
   202              else
   203                state=1
   204                cd /tmp
   205                aws s3 cp deploy-$RUNDATE.out s3://agogo-testing/
   206              fi
   207  
   208              /usr/local/bin/cfn-signal -e $state --stack ${AWS::StackName} --resource Compute --region ${AWS::Region}
   209        Tags:
   210          -
   211            Key: role
   212            Value: compute
   213      CreationPolicy:
   214        ResourceSignal:
   215          Count: 1
   216          Timeout: PT20M