blob: ffb8e9b9de798f8c606481a10135d4b89a5c5b4c [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}
Steve Bakerd6de8a22015-03-12 14:42:51 +130030
31 IPAddress:
32 Type: AWS::EC2::EIP
33 Properties:
34 InstanceId: {Ref: SmokeServer}
35
Steve Baker647b3452014-07-30 11:04:42 +120036 SmokeServer:
Steve Baker0e7ad372015-02-24 16:35:04 +130037 Type: AWS::EC2::Instance
Steve Baker647b3452014-07-30 11:04:42 +120038 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 Baker0e7ad372015-02-24 16:35:04 +130057 ImageId: {Ref: image}
58 InstanceType: {Ref: flavor}
59 KeyName: {Ref: key_name}
60 SubnetId: {Ref: subnet}
61 SecurityGroups:
Steve Baker647b3452014-07-30 11:04:42 +120062 - {Ref: SmokeSecurityGroup}
Steve Baker0e7ad372015-02-24 16:35:04 +130063 UserData:
Steve Baker647b3452014-07-30 11:04:42 +120064 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}
79Outputs:
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 Bakerd6de8a22015-03-12 14:42:51 +130087 Ref: IPAddress