blob: c95aabfcf70c5577f69707b434eac789702ec10e [file] [log] [blame]
Steve Baker647b3452014-07-30 11:04:42 +12001HeatTemplateFormatVersion: '2012-12-12'
2Description: |
3 Template which uses a wait condition to confirm that a minimal
4 cfn-init and cfn-signal has worked
5Parameters:
6 key_name:
7 Type: String
8 flavor:
9 Type: String
10 image:
11 Type: String
12 network:
13 Type: String
14 timeout:
15 Type: Number
16Resources:
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:
31 Type: OS::Nova::Server
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:
51 image: {Ref: image}
52 flavor: {Ref: flavor}
53 key_name: {Ref: key_name}
54 security_groups:
55 - {Ref: SmokeSecurityGroup}
56 networks:
57 - uuid: {Ref: network}
58 user_data:
59 Fn::Replace:
60 - WaitHandle: {Ref: WaitHandle}
61 - |
62 #!/bin/bash -v
63 /opt/aws/bin/cfn-init
64 /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" \
65 --id smoke_status "WaitHandle"
66 WaitHandle:
67 Type: AWS::CloudFormation::WaitConditionHandle
68 WaitCondition:
69 Type: AWS::CloudFormation::WaitCondition
70 DependsOn: SmokeServer
71 Properties:
72 Handle: {Ref: WaitHandle}
73 Timeout: {Ref: timeout}
74Outputs:
75 WaitConditionStatus:
76 Description: Contents of /tmp/smoke-status on SmokeServer
77 Value:
78 Fn::GetAtt: [WaitCondition, Data]
79 SmokeServerIp:
80 Description: IP address of server
81 Value:
82 Fn::GetAtt: [SmokeServer, first_address]