forked from kdkrueger/CYB260L_RDS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrds-vpc.yaml
More file actions
106 lines (97 loc) · 2.59 KB
/
rds-vpc.yaml
File metadata and controls
106 lines (97 loc) · 2.59 KB
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
# Added RDS instance
# Revision number, 1.0
# Date August 30, 2025
AWSTemplateFormatVersion: '2010-09-09'
Description: VPC (VPC-nicfra2087) in us-west-2 spanning three AZs with three subnets.
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: VPC-nicfra2087
SubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs 'us-west-2']
CidrBlock: 10.0.0.0/20
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: VPC-nicfra2087-subnet-a
SubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [1, !GetAZs 'us-west-2']
CidrBlock: 10.0.16.0/20
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: VPC-nicfra2087-subnet-b
SubnetC:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [2, !GetAZs 'us-west-2']
CidrBlock: 10.0.32.0/20
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: VPC-nicfra2087-subnet-c
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow MySQL inbound traffic
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3306
ToPort: 3306
CidrIp: 10.0.0.0/16 # restrict this to trusted IPs in production!
Tags:
- Key: Name
Value: VPC-nicfra2087-rds-sg
RdsSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Subnets for RDS instance
SubnetIds:
- !Ref SubnetA
- !Ref SubnetB
- !Ref SubnetC
Tags:
- Key: Name
Value: VPC-nicfra2087-rds-subnetgroup
RdsInstance:
Type: AWS::RDS::DBInstance
Properties:
DBSubnetGroupName: !Ref RdsSubnetGroup
VPCSecurityGroups:
- !Ref SecurityGroup
AllocatedStorage: '5'
DBInstanceClass: db.t3.micro
DBInstanceIdentifier: playground-db
Engine: MySQL
MasterUsername: Admin
MasterUserPassword: CloudAcademy123!
Outputs:
VpcId:
Description: ID of the created VPC
Value: !Ref VPC
SubnetAId:
Description: ID of Subnet A
Value: !Ref SubnetA
SubnetBId:
Description: ID of Subnet B
Value: !Ref SubnetB
SubnetCId:
Description: ID of Subnet C
Value: !Ref SubnetC
RdsEndpoint:
Description: Endpoint of the RDS instance
Value: !GetAtt RdsInstance.Endpoint.Address