Skip to content

Commit 494e39c

Browse files
Apply fmt
1 parent 368fcb1 commit 494e39c

File tree

7 files changed

+65
-65
lines changed

7 files changed

+65
-65
lines changed

main.tf

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ resource "aws_vpc" "vpc" {
88
cidr_block = var.cidr
99

1010
tags = {
11-
Name = "${var.prefix}-${var.environment}"
12-
Environment = var.environment
13-
}
11+
Name = "${var.prefix}-${var.environment}"
12+
Environment = var.environment
13+
}
1414
}
1515

1616
# AWS VPC Internet Gateway
@@ -45,20 +45,20 @@ module "nat_gateway" {
4545

4646
# AWS VPC Subnets Module - Private Subnet
4747
module "private_subnet" {
48-
source = "./modules/subnets"
49-
vpc_id = aws_vpc.vpc.id
50-
aws_nat_gateway_id = module.nat_gateway.nat_gateway_ids
51-
cidr = var.cidr
52-
prefix = var.prefix
53-
environment = var.environment
54-
subnet_bits = var.subnet_bits
55-
subnet_type = ["private", "storage"]
48+
source = "./modules/subnets"
49+
vpc_id = aws_vpc.vpc.id
50+
aws_nat_gateway_id = module.nat_gateway.nat_gateway_ids
51+
cidr = var.cidr
52+
prefix = var.prefix
53+
environment = var.environment
54+
subnet_bits = var.subnet_bits
55+
subnet_type = ["private", "storage"]
5656
}
5757

5858
# AWS VPC Security Groups Module
5959
module "security_group" {
60-
source = "./modules/security-groups"
61-
vpc_id = aws_vpc.vpc.id
62-
prefix = var.prefix
63-
environment = var.environment
60+
source = "./modules/security-groups"
61+
vpc_id = aws_vpc.vpc.id
62+
prefix = var.prefix
63+
environment = var.environment
6464
}

modules/nat-gateways/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ variable "environment" {
1010

1111
variable "public_subnet_ids" {
1212
description = "list of public subnets in order of availability zones so that NAT Gateway's can be created in those respective subnets"
13-
type = list
13+
type = list(any)
1414
}

modules/security-groups/main.tf

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# AWS Public Security Group
22
module "public_security_group" {
3-
source = "./resources"
4-
vpc_id = var.vpc_id
5-
prefix = var.prefix
6-
environment = var.environment
7-
sg_type = "public"
8-
sg_description = "Allow connections from internet"
3+
source = "./resources"
4+
vpc_id = var.vpc_id
5+
prefix = var.prefix
6+
environment = var.environment
7+
sg_type = "public"
8+
sg_description = "Allow connections from internet"
99
}
1010

1111
# AWS Public Security Group Rules
@@ -29,40 +29,40 @@ resource "aws_security_group_rule" "allow_https_inbound_public" {
2929

3030
# AWS Private Security Group
3131
module "private_security_group" {
32-
source = "./resources"
33-
vpc_id = var.vpc_id
34-
prefix = var.prefix
35-
environment = var.environment
36-
sg_type = "private"
37-
sg_description = "The private security group to allows inbound traffic from public group"
32+
source = "./resources"
33+
vpc_id = var.vpc_id
34+
prefix = var.prefix
35+
environment = var.environment
36+
sg_type = "private"
37+
sg_description = "The private security group to allows inbound traffic from public group"
3838
}
3939

4040
# AWS Private Security Group Rules
4141
resource "aws_security_group_rule" "allow_inbound_private" {
42-
type = "ingress"
43-
from_port = 0
44-
to_port = 65535
45-
protocol = "-1"
46-
source_security_group_id = module.public_security_group.security_group_id
47-
security_group_id = module.private_security_group.security_group_id
42+
type = "ingress"
43+
from_port = 0
44+
to_port = 65535
45+
protocol = "-1"
46+
source_security_group_id = module.public_security_group.security_group_id
47+
security_group_id = module.private_security_group.security_group_id
4848
}
4949

5050
# AWS Storage Security Group
5151
module "storage_security_group" {
52-
source = "./resources"
53-
vpc_id = var.vpc_id
54-
prefix = var.prefix
55-
environment = var.environment
56-
sg_type = "storage"
57-
sg_description = "The storage security group to allows inbound traffic from private group"
52+
source = "./resources"
53+
vpc_id = var.vpc_id
54+
prefix = var.prefix
55+
environment = var.environment
56+
sg_type = "storage"
57+
sg_description = "The storage security group to allows inbound traffic from private group"
5858
}
5959

6060
# AWS Storage Security Group Rules
6161
resource "aws_security_group_rule" "allow_inbound_storage" {
62-
type = "ingress"
63-
from_port = 0
64-
to_port = 65535
65-
protocol = "-1"
66-
source_security_group_id = module.private_security_group.security_group_id
67-
security_group_id = module.storage_security_group.security_group_id
62+
type = "ingress"
63+
from_port = 0
64+
to_port = 65535
65+
protocol = "-1"
66+
source_security_group_id = module.private_security_group.security_group_id
67+
security_group_id = module.storage_security_group.security_group_id
6868
}

modules/security-groups/resources/main.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# AWS Security Group
2-
resource "aws_security_group" "security_group" {
3-
name = "${var.prefix}-${var.sg_type}"
4-
description = var.sg_description
5-
vpc_id = var.vpc_id
6-
revoke_rules_on_delete = true
2+
resource "aws_security_group" "security_group" {
3+
name = "${var.prefix}-${var.sg_type}"
4+
description = var.sg_description
5+
vpc_id = var.vpc_id
6+
revoke_rules_on_delete = true
77

8-
tags = {
9-
Name = "${var.prefix}-${var.sg_type}"
10-
Type = var.sg_type
11-
Environment = var.environment
12-
}
8+
tags = {
9+
Name = "${var.prefix}-${var.sg_type}"
10+
Type = var.sg_type
11+
Environment = var.environment
12+
}
1313
}
1414

1515
# AWS Outbound Security Group Rule

modules/subnets/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ resource "aws_route" "public_route" {
4949

5050
# AWS Route Tables - Private Route
5151
resource "aws_route" "private_route" {
52-
count = contains(var.subnet_type, "private") ? length(data.aws_availability_zones.available_zones.names) : 0
53-
route_table_id = module.aws_private_subnet.route_table_ids[count.index]
54-
destination_cidr_block = "0.0.0.0/0"
55-
nat_gateway_id = var.aws_nat_gateway_id[count.index]
52+
count = contains(var.subnet_type, "private") ? length(data.aws_availability_zones.available_zones.names) : 0
53+
route_table_id = module.aws_private_subnet.route_table_ids[count.index]
54+
destination_cidr_block = "0.0.0.0/0"
55+
nat_gateway_id = var.aws_nat_gateway_id[count.index]
5656
}

modules/subnets/resources/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ resource "aws_route_table" "route_table" {
2929

3030
# AWS Route Table - Subnet Association
3131
resource "aws_route_table_association" "subnet_association" {
32-
count = var.create > 0 ? length(data.aws_availability_zones.available_zones.names) : 0
33-
subnet_id = element(aws_subnet.subnets.*.id, count.index)
34-
route_table_id = element(aws_route_table.route_table.*.id, count.index)
32+
count = var.create > 0 ? length(data.aws_availability_zones.available_zones.names) : 0
33+
subnet_id = element(aws_subnet.subnets.*.id, count.index)
34+
route_table_id = element(aws_route_table.route_table.*.id, count.index)
3535
}

modules/subnets/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ variable "aws_internet_gateway_id" {
1111

1212
variable "aws_nat_gateway_id" {
1313
description = "NAT Gateway ids sort by the availability zone names to bind with the subnet mask in respective AZs"
14-
type = list
14+
type = list(any)
1515
default = [""]
1616
}
1717

@@ -32,7 +32,7 @@ variable "subnet_bits" {
3232

3333
variable "subnet_type" {
3434
description = "List of type of subnet Eg: ['public', 'private']"
35-
type = list
35+
type = list(any)
3636
}
3737

3838
variable "cidr" {

0 commit comments

Comments
 (0)