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