-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAWS-STL-Meetup-08.yaml
96 lines (80 loc) · 2.07 KB
/
AWS-STL-Meetup-08.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
# Add and associate a route table with a default route to the Internet Gateway
Parameters:
VpcCidr:
Default: 10.10.0.0/16
Type: String
PublicSubnetCidr:
Default: 10.10.0.0/24
Type: String
ImageId:
Default: ami-0d8f6eb4f641ef691
Type: String
InstanceType:
Default: t3.micro
Type: String
KeyName:
Default: AWS-STL-Meetup
Type: String
WebInstanceIp:
Default: 10.10.0.10
Type: String
Resources:
Vpc:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: !Ref VpcCidr
PublicSubnet:
Type: "AWS::EC2::Subnet"
Properties:
CidrBlock: !Ref PublicSubnetCidr
VpcId: !Ref Vpc
WebSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: Web Security Group
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 80
IpProtocol: tcp
ToPort: 80
- CidrIp: 0.0.0.0/0
FromPort: -1
IpProtocol: icmp
ToPort: -1
VpcId: !Ref Vpc
WebInstance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !Ref ImageId
InstanceType: !Ref InstanceType
KeyName: !Ref KeyName
SecurityGroupIds:
- !Ref WebSecurityGroup
SubnetId: !Ref PublicSubnet
PrivateIpAddress: !Ref WebInstanceIp
WebInstanceElasticIp:
Type: "AWS::EC2::EIP"
Properties:
InstanceId: !Ref WebInstance
InternetGateway:
Type: "AWS::EC2::InternetGateway"
InternetGatewayAttachment:
Type: "AWS::EC2::VPCGatewayAttachment"
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref Vpc
PublicSubnetRouteTable:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref Vpc
PublicSubnetRouteTableAssociation:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
RouteTableId: !Ref PublicSubnetRouteTable
SubnetId: !Ref PublicSubnet
PublicSubnetDefaultRoute:
Type: "AWS::EC2::Route"
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
RouteTableId: !Ref PublicSubnetRouteTable