-
Notifications
You must be signed in to change notification settings - Fork 1
/
novrouter.yaml
114 lines (114 loc) · 2.77 KB
/
novrouter.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
AWSTemplateFormatVersion: '2010-09-09'
Description: Student VPC, subnets, route tables, igw, sg, test VM
Parameters:
ID:
Description: ID Number of student
Type: String
Default: 5
VPCCidr:
Description: Subnet for VPC
Type: String
Default: 10.5.0.0/16
Subnet1Cidr:
Description: Subnet for subnet 1
Type: String
Default: 10.5.1.0/24
Subnet2Cidr:
Description: Subnet for subnet 2
Type: String
Default: 10.5.11.0/24
Resources:
studentvpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VPCCidr
Tags:
- Key: Name
Value: !Sub
- VPC-${ID}
- {ID: !Ref ID}
veossg:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow SSH and VPC
VpcId: !Ref 'studentvpc'
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0
- IpProtocol: -1
CidrIp: 10.0.0.0/8
- IpProtocol: icmp
FromPort: -1
ToPort: -1
CidrIp: 10.0.0.0/8
Tags:
- Key: Name
Value: !Sub
- vpc-${ID}-security-group
- {ID: !Ref ID}
studentvpcigw:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub
- VPC-${ID}-IGW
- {ID: !Ref ID}
AttachGW:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref 'studentvpc'
InternetGatewayId: !Ref 'studentvpcigw'
subnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref 'studentvpc'
CidrBlock: !Ref Subnet1Cidr
AvailabilityZone: us-west-2a
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Ref Subnet1Cidr
subnet1RT:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref 'studentvpc'
Tags:
- Key: Name
Value: !Ref Subnet1Cidr
publicRoute:
Type: AWS::EC2::Route
DependsOn: AttachGW
Properties:
RouteTableId: !Ref 'subnet2RT'
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref 'studentvpcigw'
PublicRTAssoc:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref subnet1
RouteTableId: !Ref subnet1RT
subnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref 'studentvpc'
CidrBlock: !Ref Subnet2Cidr
AvailabilityZone: us-west-2a
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Ref Subnet2Cidr
subnet2RT:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref 'studentvpc'
Tags:
- Key: Name
Value: !Ref Subnet2Cidr
subnet2RTAssoc:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref subnet2
RouteTableId: !Ref subnet2RT