-
Notifications
You must be signed in to change notification settings - Fork 1
/
multiregion-ec2.yaml
67 lines (66 loc) · 1.97 KB
/
multiregion-ec2.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
Mappings:
# AMI Mappings per region
RegionMap:
us-east-2:
"64": "ami-4191b524"
us-west-2:
"64": "ami-4836a428"
eu-west-1:
"64": "ami-01ccc867"
ap-southeast-2:
"64": "ami-162c2575"
ap-northeast-1:
"64": "ami-923d12f5"
# Private Keys per region
KeyMap:
us-east-2:
"0": "us-east-2-demo"
us-west-2:
"0": "us-west-2-demo"
eu-west-1:
"0": "eu-west-1-demo"
ap-southeast-2:
"0": "ap-se-2-demo"
ap-northeast-1:
"0": "ap-ne-1-demo"
Resources:
Ec2Instance:
Type: AWS::EC2::Instance
Properties:
SecurityGroups:
- Ref: InstanceSecurityGroup
KeyName: !FindInMap [ KeyMap, !Ref "AWS::Region", 0 ]
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", 64 ]
InstanceType: t2.micro
UserData: !Base64
"Fn::Join": ["", ["#!/bin/bash\n","yum install -y httpd\n", "service httpd start\n"]]
Tags:
-
Key: Name
Value: "CloudTracer - Fred"
# Need to add script to install webserver and start it
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable SSH, HTTP, ICMP
SecurityGroupIngress:
- 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: icmp
FromPort: '-1'
ToPort: '-1'
CidrIp: 0.0.0.0/0
# Get output of the IP address of the VM
Outputs:
Ec2IP:
Description: EC2 IP Address
Value: !GetAtt Ec2Instance.PublicIp
EcID:
Description: EC2 ID
Value: !Ref Ec2Instance