-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcfn-simple-amazon-linux-web.yaml
More file actions
70 lines (65 loc) · 2.02 KB
/
cfn-simple-amazon-linux-web.yaml
File metadata and controls
70 lines (65 loc) · 2.02 KB
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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates an Amazon Linux Web Server based on https://github.com/widdix/learn-cloudformation/blob/master/lab0-create-stack/demo.yaml, last access 9/6/2017, and on https://github.com/widdix/learn-cloudformation/blob/master/lab8-cfn-init/stub.yaml, last access 9/17/2017
Mappings:
RegionMap:
us-east-1:
AMI: ami-4fffc834
us-east-2:
AMI: ami-ea87a78f
Resources:
EC2Instance:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
config:
packages:
yum:
httpd: []
files:
"/var/www/html/index.html":
content: |
<html>
<body>
<h1>Dr. V's CloudFormed Server</h1>
<h2>with CloudFormation Helper Scripts</h2>
<p>Hello World!</p>
</body>
</html>
mode: '000644'
owner: root
group: root
services:
sysvinit:
httpd:
enabled: 'true'
ensureRunning: 'true'
Properties:
ImageId: !FindInMap [RegionMap, !Ref 'AWS::Region', 'AMI']
InstanceType: t2.micro
SecurityGroups:
- !Ref WebserverSecurityGroup
Tags:
- Key: Name
Value: Amazon Linux Web Server
UserData:
'Fn::Base64': !Sub |
#!/bin/bash -ex
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v -s ${AWS::StackName} -r EC2Instance --region ${AWS::Region}
WebserverSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: hello-world-webserver
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 80
IpProtocol: tcp
ToPort: 80
Outputs:
HelloWorldURL:
Description: The url pointing to our page.
Value: !Sub 'http://${EC2Instance.PublicIp}'
PublicDNS:
Description: The Public DNS
Value: !Sub '${EC2Instance.PublicDnsName}'