-
Notifications
You must be signed in to change notification settings - Fork 0
/
4-Paramters.yaml
96 lines (83 loc) · 2.78 KB
/
4-Paramters.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
Parameters:
SecurityGroupDescription:
Description: Security Group Description (Simple parameter)
Type: String
SecurityGroupPort:
Description: Simple Description of a Number Parameter, with MinValue and MaxValue
Type: Number
MinValue: 1150
MaxValue: 65535
InstanceType:
Description: WebServer EC2 instance type (has default, AllowedValues)
Type: String
Default: t2.small
AllowedValues:
- t1.micro
- t2.nano
- t2.micro
- t2.small
ConstraintDescription: must be a valid EC2 instance type.
DBPwd:
NoEcho: true
Description: The database admin account password (won't be echoed)
Type: String
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances. Linked to AWS Parameter
Type: AWS::EC2::KeyPair::KeyName
ConstraintDescription: must be the name of an existing EC2 KeyPair.
SecurityGroupIngressCIDR:
Description: The IP address range that can be used to communicate to the EC2 instances
Type: String
MinLength: "9"
MaxLength: "18"
Default: 0.0.0.0/0
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
MyVPC:
Description: VPC to operate in
Type: AWS::EC2::VPC::Id
MySubnetIDs:
Description: Subnet IDs that is a List of Subnet Id
Type: "List<AWS::EC2::Subnet::Id>"
DbSubnetIpBlocks:
Description: "Comma-delimited list of three CIDR blocks"
Type: CommaDelimitedList
Default: "10.0.48.0/24, 10.0.112.0/24, 10.0.176.0/24"
Resources:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
#we reference the InstanceType parameter
InstanceType: !Ref InstanceType
KeyName: !Ref KeyName
ImageId: ami-0742b4e673072066f
# here we reference an internal CloudFormation resource
SubnetId: !Ref DbSubnet1
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: !Ref SecurityGroupDescription
SecurityGroupIngress:
- CidrIp: !Ref SecurityGroupIngressCIDR
FromPort: !Ref SecurityGroupPort
ToPort: !Ref SecurityGroupPort
IpProtocol: tcp
VpcId: !Ref MyVPC
DbSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref MyVPC
# the select function allows us to select across a list
CidrBlock: !Select [0, !Ref DbSubnetIpBlocks]
DbSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref MyVPC
# the select function allows us to select across a list
CidrBlock: !Select [1, !Ref DbSubnetIpBlocks]
DbSubnet3:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref MyVPC
# the select function allows us to select across a list
CidrBlock: !Select [2, !Ref DbSubnetIpBlocks]