Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 1 | HeatTemplateFormatVersion: '2012-12-12' |
| 2 | Description: | |
| 3 | Template which uses a wait condition to confirm that a minimal |
| 4 | cfn-init and cfn-signal has worked |
| 5 | Parameters: |
| 6 | key_name: |
| 7 | Type: String |
| 8 | flavor: |
| 9 | Type: String |
| 10 | image: |
| 11 | Type: String |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 12 | subnet: |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 13 | Type: String |
| 14 | timeout: |
| 15 | Type: Number |
| 16 | Resources: |
| 17 | CfnUser: |
| 18 | Type: AWS::IAM::User |
| 19 | SmokeSecurityGroup: |
| 20 | Type: AWS::EC2::SecurityGroup |
| 21 | Properties: |
| 22 | GroupDescription: Enable only ping and SSH access |
| 23 | SecurityGroupIngress: |
| 24 | - {CidrIp: 0.0.0.0/0, FromPort: '-1', IpProtocol: icmp, ToPort: '-1'} |
| 25 | - {CidrIp: 0.0.0.0/0, FromPort: '22', IpProtocol: tcp, ToPort: '22'} |
| 26 | SmokeKeys: |
| 27 | Type: AWS::IAM::AccessKey |
| 28 | Properties: |
| 29 | UserName: {Ref: CfnUser} |
Steve Baker | d6de8a2 | 2015-03-12 14:42:51 +1300 | [diff] [blame] | 30 | |
Rakesh H S | eecee65 | 2015-07-15 17:44:41 +0530 | [diff] [blame] | 31 | ElasticIp: |
Steve Baker | d6de8a2 | 2015-03-12 14:42:51 +1300 | [diff] [blame] | 32 | Type: AWS::EC2::EIP |
| 33 | Properties: |
Rakesh H S | eecee65 | 2015-07-15 17:44:41 +0530 | [diff] [blame] | 34 | Domain: vpc |
| 35 | |
| 36 | SmokeServerElasticIp: |
| 37 | Type: AWS::EC2::EIPAssociation |
| 38 | Properties: |
| 39 | EIP: {Ref: ElasticIp} |
| 40 | InstanceId: {Ref: SmokeServer} |
Steve Baker | d6de8a2 | 2015-03-12 14:42:51 +1300 | [diff] [blame] | 41 | |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 42 | SmokeServer: |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 43 | Type: AWS::EC2::Instance |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 44 | Metadata: |
| 45 | AWS::CloudFormation::Init: |
| 46 | config: |
| 47 | files: |
| 48 | /tmp/smoke-status: |
| 49 | content: smoke test complete |
| 50 | /etc/cfn/cfn-credentials: |
| 51 | content: |
| 52 | Fn::Replace: |
| 53 | - SmokeKeys: {Ref: SmokeKeys} |
| 54 | SecretAccessKey: |
| 55 | 'Fn::GetAtt': [SmokeKeys, SecretAccessKey] |
| 56 | - | |
| 57 | AWSAccessKeyId=SmokeKeys |
| 58 | AWSSecretKey=SecretAccessKey |
| 59 | mode: '000400' |
| 60 | owner: root |
| 61 | group: root |
| 62 | Properties: |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 63 | ImageId: {Ref: image} |
| 64 | InstanceType: {Ref: flavor} |
| 65 | KeyName: {Ref: key_name} |
| 66 | SubnetId: {Ref: subnet} |
| 67 | SecurityGroups: |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 68 | - {Ref: SmokeSecurityGroup} |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 69 | UserData: |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 70 | Fn::Replace: |
| 71 | - WaitHandle: {Ref: WaitHandle} |
| 72 | - | |
| 73 | #!/bin/bash -v |
| 74 | /opt/aws/bin/cfn-init |
| 75 | /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" \ |
| 76 | --id smoke_status "WaitHandle" |
| 77 | WaitHandle: |
| 78 | Type: AWS::CloudFormation::WaitConditionHandle |
| 79 | WaitCondition: |
| 80 | Type: AWS::CloudFormation::WaitCondition |
| 81 | DependsOn: SmokeServer |
| 82 | Properties: |
| 83 | Handle: {Ref: WaitHandle} |
| 84 | Timeout: {Ref: timeout} |
| 85 | Outputs: |
| 86 | WaitConditionStatus: |
| 87 | Description: Contents of /tmp/smoke-status on SmokeServer |
| 88 | Value: |
| 89 | Fn::GetAtt: [WaitCondition, Data] |
Rakesh H S | eecee65 | 2015-07-15 17:44:41 +0530 | [diff] [blame] | 90 | ElasticIp_Id: |
| 91 | Description: Elastic ip allocation id |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 92 | Value: |
Rakesh H S | eecee65 | 2015-07-15 17:44:41 +0530 | [diff] [blame] | 93 | Fn::GetAtt: [ElasticIp, AllocationId] |
| 94 | SmokeServerElasticIp: |
| 95 | Description: Elastic ip address of server |
| 96 | Value: |
| 97 | Ref: ElasticIp |