Skip to content

Commit bb36fc9

Browse files
committed
Final Fix
1 parent d72c8d1 commit bb36fc9

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

hometask7/main.tf

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Create a custom VPC
22
resource "aws_vpc" "my_vpc" {
3-
cidr_block = "10.0.0.0/16"
3+
cidr_block = "10.10.0.0/16"
4+
enable_dns_support = "true"
5+
enable_dns_hostnames = "true"
46
}
57

68
# Create Internet Gateway
@@ -21,14 +23,14 @@ resource "aws_route_table" "my_route_table" {
2123
# Create Subnets
2224
resource "aws_subnet" "my_subnet1" {
2325
vpc_id = aws_vpc.my_vpc.id
24-
cidr_block = "10.0.0.0/24"
26+
cidr_block = "10.10.1.0/24"
2527
map_public_ip_on_launch = "true"
2628
availability_zone = "us-east-1a"
2729
}
2830

2931
resource "aws_subnet" "my_subnet2" {
3032
vpc_id = aws_vpc.my_vpc.id
31-
cidr_block = "10.0.1.0/24"
33+
cidr_block = "10.10.2.0/24"
3234
map_public_ip_on_launch = "true"
3335
availability_zone = "us-east-1b"
3436
}
@@ -43,27 +45,12 @@ resource "aws_route_table_association" "table_association2" {
4345
route_table_id = aws_route_table.my_route_table.id
4446
}
4547

46-
4748
# Create Security Group to allow port 80
4849
resource "aws_security_group" "allow_web" {
4950
name = "allow_web_traffic"
5051
description = "Allow Web inbound traffic"
5152
vpc_id = aws_vpc.my_vpc.id
5253

53-
ingress {
54-
description = "HTTP"
55-
from_port = 80
56-
to_port = 80
57-
protocol = "tcp"
58-
cidr_blocks = ["0.0.0.0/0"]
59-
}
60-
ingress {
61-
description = "SSH"
62-
from_port = 22
63-
to_port = 22
64-
protocol = "tcp"
65-
cidr_blocks = ["0.0.0.0/0"]
66-
}
6754
ingress {
6855
from_port = 3306
6956
to_port = 3306
@@ -92,11 +79,11 @@ resource "aws_network_acl" "bar" {
9279
resource "aws_network_acl_rule" "bar" {
9380
network_acl_id = aws_network_acl.bar.id
9481
rule_number = 100
95-
protocol = "tcp"
82+
protocol = -1
9683
rule_action = "deny"
9784
cidr_block = "50.31.252.0/24"
98-
from_port = 80
99-
to_port = 80
85+
from_port = 0
86+
to_port = 0
10087
}
10188

10289
# Add DB subnet group
@@ -110,16 +97,19 @@ variable "MYSQL_PWD" {}
11097

11198
# Create RDS Instance
11299
resource "aws_db_instance" "my_instance" {
113-
allocated_storage = 10
100+
identifier = "mysqldb"
114101
db_name = "dbtest"
115102
engine = "mysql"
116103
engine_version = "5.7"
117104
instance_class = "db.t2.micro"
118105
username = "testuser"
119106
password = var.MYSQL_PWD
120107
port = "3306"
108+
storage_type = "gp2"
109+
allocated_storage = 20
121110
vpc_security_group_ids = [aws_security_group.allow_web.id]
122111
db_subnet_group_name = aws_db_subnet_group.db_sg.id
123112
parameter_group_name = "default.mysql5.7"
124113
skip_final_snapshot = true
114+
publicly_accessible = true
125115
}

0 commit comments

Comments
 (0)