forked from NeCTAR-RC/heat-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapache_single_instance_aws.yaml
108 lines (91 loc) · 3.65 KB
/
apache_single_instance_aws.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# http://docs.openstack.org/developer/heat/template_guide/hot_spec.html#heat-template-version
heat_template_version: 2014-10-16
description: Install Apache on a single Debian instance using the AWS::EC2::Instance type.
parameters:
key_name:
type: string
label: Key Name
description: Name of an existing KeyPair to enable SSH access to the instances.
image_name:
type: string
label: Image ID
description: Image to be used for compute instance
default: Debian_8
constraints:
- allowed_values: [ Debian_7, Debian_8 ]
description: Value must be one of Debian_6, Debian_7 or Debian_8
instance_type:
type: string
description: The NeCTAR flavour the webserver is to run on
default: m2.xsmall
constraints:
- allowed_values: [m2.xsmall, m2.small, m1.small]
description:
Must be a valid NeCTAR flavour, limited to the smaller ones available
resources:
# Use this when we do not have Neutron networking.
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::EC2::SecurityGroup
web_security_group:
type: AWS::EC2::SecurityGroup
properties:
GroupDescription: Web server access rules.
SecurityGroupIngress:
- {IpProtocol: icmp, FromPort: '-1', ToPort: '-1', CidrIp : 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '22', ToPort: '22', CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '80', ToPort: '80', CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '443', ToPort: '443', CidrIp: 0.0.0.0/0}
apache_server:
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::EC2::Instance
type: AWS::EC2::Instance
# A deletion policy of Retain will leave this instance behind when this template is torn down.
# deletion_policy: Retain
metadata:
AWS::CloudFormation::Init:
config:
packages:
apt:
apache2: []
services:
systemd:
apache2: {enabled: 'true', ensureRunning: 'true'}
properties:
ImageId:
Fn::Select:
- { get_param: image_name }
-
Debian_7: 6917afc4-1732-4ca2-aa11-09a289a8494e
Debian_8: daf6e64d-10d1-4038-a6f8-bf51c112a8cd
InstanceType: { get_param: instance_type }
KeyName: { get_param: key_name }
SecurityGroups: [ get_resource: web_security_group ]
# the following is written to /var/lib/cloud/data/cfn-userdata
# note the call to cfn-init which causes the AWS::CloudFomration::Init to be actioned
UserData:
str_replace:
template: |
#!/bin/bash -v
/usr/bin/cfn-init
# now signal the install is finished
/opt/aws/bin/cfn-signal -e 0 -r "Command line tools server setup complete" 'WaitHandle'
params:
WaitHandle: { get_resource: wait_handle }
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::CloudFormation::WaitConditionHandle
wait_handle:
type: 'AWS::CloudFormation::WaitConditionHandle'
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::CloudFormation::WaitCondition
wait_condition:
type: AWS::CloudFormation::WaitCondition
depends_on: apache_server
properties:
Handle: { get_resource: wait_handle }
Count: 1
# we'll give it 10 minutes
Timeout: 600
outputs:
instance_ip:
description: The IP address of the deployed instance
value: { get_attr: [apache_server, PublicIp] }
website_url:
description: URL for Apache server
value:
list_join: ['', ['http://', get_attr: [apache_server, PublicIp]]]