-
Notifications
You must be signed in to change notification settings - Fork 1
/
ec2_instance_v2.yaml
86 lines (77 loc) · 2.46 KB
/
ec2_instance_v2.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
### Compliled by Shanil Hirani - V2 ###
### EC2 Instance Template with various comments to aid in Instance Deployment. ###
AWSTemplateFormatVersion: 2010-09-09
Description: Deploys Two EC2 Instances based Amazon AMI. In a Private and Public Subnet for a simple Front and Backend App.
### Configure Parameters as needed ###
Parameters:
PrivateInstanceName:
Description: Name of your Private instance?
Type: String
Default: I_did_not_name_my_ec2_instance
PublicInstanceName:
Description: Name of your Public instance?
Type: String
Default: I_did_not_name_my_ec2_instance
InstanceSize:
Description: Enter t2.micro, m1.small, or m1.large. Default is t2.micro.
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- m1.small
- m1.large
KeyPair:
Description: Key Pair
Type: String
Default: sh-kp
AMIid:
Description: AMI ID
Type: AWS::EC2::Image::Id
Default: ami-09ead922c1dad67e4
### EC2 Resources deployed as below specs - This will be changed to use Parements and !Refs in later revisions.
Resources:
### Private Instance
EC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: !Ref InstanceSize
ImageId: !Ref AMIid
KeyName: !Ref KeyPair
SecurityGroupIds:
- !ImportValue multi-az-vpc-sg-private
SubnetId: !Select [0, !Split [",", !ImportValue multi-az-vpc-private-subnet-id]]
Tags:
- Key: Name
Value: !Ref PrivateInstanceName
### Public Instance
EC2Instance2:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: !Ref InstanceSize
ImageId: !Ref AMIid
KeyName: !Ref KeyPair
SecurityGroupIds:
- !ImportValue multi-az-vpc-sg-public
SubnetId: !Select [0, !Split [",", !ImportValue multi-az-vpc-public-subnet-id]]
Tags:
- Key: Name
Value: !Ref PublicInstanceName
#### Outputs
Outputs:
EC2InstanceName:
Description: Instance Name
Value: !Join [",",[!Ref EC2Instance, !Ref EC2Instance2]]
EC2InstanceAZ:
Description: Availability Zone of the newly created EC2 instance
Value: !Join [",",[!Ref EC2Instance, !Ref EC2Instance2]]
### Public Instance
PublicDNS:
Description: Public DNSName of the newly created Public instance
Value: !GetAtt
- EC2Instance2
- PublicDnsName
PublicIP:
Description: Public IP address of the newly created Public instance
Value: !GetAtt
- EC2Instance2
- PublicIp