blob: 681e5390cae1fcd91046a37d45eaed1ae2cba486 [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
Steve Baker0e7ad372015-02-24 16:35:04 +130012 subnet:
Steve Baker647b3452014-07-30 11:04:42 +120013 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:
Steve Baker0e7ad372015-02-24 16:35:04 +130031 Type: AWS::EC2::Instance
Steve Baker647b3452014-07-30 11:04:42 +120032 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 Baker0e7ad372015-02-24 16:35:04 +130051 ImageId: {Ref: image}
52 InstanceType: {Ref: flavor}
53 KeyName: {Ref: key_name}
54 SubnetId: {Ref: subnet}
55 SecurityGroups:
Steve Baker647b3452014-07-30 11:04:42 +120056 - {Ref: SmokeSecurityGroup}
Steve Baker0e7ad372015-02-24 16:35:04 +130057 UserData:
Steve Baker647b3452014-07-30 11:04:42 +120058 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}
73Outputs:
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 Baker0e7ad372015-02-24 16:35:04 +130081 Fn::GetAtt: [SmokeServer, PublicIp]