blob: 9f947170a3ddd4e5d9ceab641f0c2449e29d729f [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
Rakesh H Seecee652015-07-15 17:44:41 +053031 ElasticIp:
Steve Bakerd6de8a22015-03-12 14:42:51 +130032 Type: AWS::EC2::EIP
33 Properties:
Rakesh H Seecee652015-07-15 17:44:41 +053034 Domain: vpc
35
36 SmokeServerElasticIp:
37 Type: AWS::EC2::EIPAssociation
38 Properties:
39 EIP: {Ref: ElasticIp}
40 InstanceId: {Ref: SmokeServer}
Steve Bakerd6de8a22015-03-12 14:42:51 +130041
Steve Baker647b3452014-07-30 11:04:42 +120042 SmokeServer:
Steve Baker0e7ad372015-02-24 16:35:04 +130043 Type: AWS::EC2::Instance
Steve Baker647b3452014-07-30 11:04:42 +120044 Metadata:
45 AWS::CloudFormation::Init:
46 config:
47 files:
48 /tmp/smoke-status:
49 content: smoke test complete
50 /etc/cfn/cfn-credentials:
51 content:
52 Fn::Replace:
53 - SmokeKeys: {Ref: SmokeKeys}
54 SecretAccessKey:
55 'Fn::GetAtt': [SmokeKeys, SecretAccessKey]
56 - |
57 AWSAccessKeyId=SmokeKeys
58 AWSSecretKey=SecretAccessKey
59 mode: '000400'
60 owner: root
61 group: root
62 Properties:
Steve Baker0e7ad372015-02-24 16:35:04 +130063 ImageId: {Ref: image}
64 InstanceType: {Ref: flavor}
65 KeyName: {Ref: key_name}
66 SubnetId: {Ref: subnet}
67 SecurityGroups:
Steve Baker647b3452014-07-30 11:04:42 +120068 - {Ref: SmokeSecurityGroup}
Steve Baker0e7ad372015-02-24 16:35:04 +130069 UserData:
Steve Baker647b3452014-07-30 11:04:42 +120070 Fn::Replace:
71 - WaitHandle: {Ref: WaitHandle}
72 - |
73 #!/bin/bash -v
74 /opt/aws/bin/cfn-init
75 /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" \
76 --id smoke_status "WaitHandle"
77 WaitHandle:
78 Type: AWS::CloudFormation::WaitConditionHandle
79 WaitCondition:
80 Type: AWS::CloudFormation::WaitCondition
81 DependsOn: SmokeServer
82 Properties:
83 Handle: {Ref: WaitHandle}
84 Timeout: {Ref: timeout}
85Outputs:
86 WaitConditionStatus:
87 Description: Contents of /tmp/smoke-status on SmokeServer
88 Value:
89 Fn::GetAtt: [WaitCondition, Data]
Rakesh H Seecee652015-07-15 17:44:41 +053090 ElasticIp_Id:
91 Description: Elastic ip allocation id
Steve Baker647b3452014-07-30 11:04:42 +120092 Value:
Rakesh H Seecee652015-07-15 17:44:41 +053093 Fn::GetAtt: [ElasticIp, AllocationId]
94 SmokeServerElasticIp:
95 Description: Elastic ip address of server
96 Value:
97 Ref: ElasticIp