-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.yml
66 lines (66 loc) · 1.75 KB
/
demo.yml
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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: A test stack for demonstrating Cloudformation
Parameters:
Subnet:
Description: Subnet in which to place the resources
Type: AWS::EC2::Subnet::Id
SecurityGroup:
Description: This group will be applied to both the ELB and instances in the ASG
Type: AWS::EC2::SecurityGroup::Id
KeyName:
Description: The ssh key you want to use for instances
Type: AWS::EC2::KeyPair::KeyName
InstanceType:
Description: The instance type for the Launch Config
Type: String
Default: t2.micro
AllowedValues:
- t2.nano
- t2.micro
- t2.small
- t2.medium
- t2.large
Resources:
MyLoadBalancer:
Type: AWS::ElasticLoadBalancing::LoadBalancer
Properties:
Listeners:
- LoadBalancerPort: 80
InstancePort: 80
Protocol: HTTP
Subnets:
- Ref: Subnet
SecurityGroups:
- Ref: SecurityGroup
MyLaunchConfiguration:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
yum install nginx -y
sudo service nginx start
ImageId: ami-6869aa05
InstanceType:
Ref: InstanceType
KeyName:
Ref: KeyName
SecurityGroups:
- Ref: SecurityGroup
MyAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
LoadBalancerNames:
- Ref: MyLoadBalancer
LaunchConfigurationName:
Ref: MyLaunchConfiguration
DesiredCapacity: 1
MinSize: 1
MaxSize: 4
VPCZoneIdentifier:
- Ref: Subnet
Outputs:
LoadBalancerDNSName:
Description: The DNS name of the ELB
Value: !GetAtt MyLoadBalancer.DNSName