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} |
| 30 | SmokeServer: |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 31 | Type: AWS::EC2::Instance |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 32 | Metadata: |
| 33 | AWS::CloudFormation::Init: |
| 34 | config: |
| 35 | files: |
| 36 | /tmp/smoke-status: |
| 37 | content: smoke test complete |
| 38 | /etc/cfn/cfn-credentials: |
| 39 | content: |
| 40 | Fn::Replace: |
| 41 | - SmokeKeys: {Ref: SmokeKeys} |
| 42 | SecretAccessKey: |
| 43 | 'Fn::GetAtt': [SmokeKeys, SecretAccessKey] |
| 44 | - | |
| 45 | AWSAccessKeyId=SmokeKeys |
| 46 | AWSSecretKey=SecretAccessKey |
| 47 | mode: '000400' |
| 48 | owner: root |
| 49 | group: root |
| 50 | Properties: |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 51 | ImageId: {Ref: image} |
| 52 | InstanceType: {Ref: flavor} |
| 53 | KeyName: {Ref: key_name} |
| 54 | SubnetId: {Ref: subnet} |
| 55 | SecurityGroups: |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 56 | - {Ref: SmokeSecurityGroup} |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 57 | UserData: |
Steve Baker | 647b345 | 2014-07-30 11:04:42 +1200 | [diff] [blame] | 58 | Fn::Replace: |
| 59 | - WaitHandle: {Ref: WaitHandle} |
| 60 | - | |
| 61 | #!/bin/bash -v |
| 62 | /opt/aws/bin/cfn-init |
| 63 | /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" \ |
| 64 | --id smoke_status "WaitHandle" |
| 65 | WaitHandle: |
| 66 | Type: AWS::CloudFormation::WaitConditionHandle |
| 67 | WaitCondition: |
| 68 | Type: AWS::CloudFormation::WaitCondition |
| 69 | DependsOn: SmokeServer |
| 70 | Properties: |
| 71 | Handle: {Ref: WaitHandle} |
| 72 | Timeout: {Ref: timeout} |
| 73 | Outputs: |
| 74 | WaitConditionStatus: |
| 75 | Description: Contents of /tmp/smoke-status on SmokeServer |
| 76 | Value: |
| 77 | Fn::GetAtt: [WaitCondition, Data] |
| 78 | SmokeServerIp: |
| 79 | Description: IP address of server |
| 80 | Value: |
Steve Baker | 0e7ad37 | 2015-02-24 16:35:04 +1300 | [diff] [blame] | 81 | Fn::GetAtt: [SmokeServer, PublicIp] |