Skip to content

Commit e6dcba3

Browse files
committed
fix var vpc_ep
1 parent 135695f commit e6dcba3

File tree

5 files changed

+78
-78
lines changed

5 files changed

+78
-78
lines changed

main.tf

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -448,82 +448,4 @@ resource "aws_iam_role_policy" "flow_logs_policy" {
448448
]
449449
}
450450
EOF
451-
}
452-
453-
## VPC Peering
454-
resource "aws_vpc_peering_connection" "main" {
455-
count = var.create ? length(var.vpc_peering_connection) : 0
456-
457-
depends_on = [ aws_vpc.main ]
458-
459-
peer_vpc_id = lookup(var.vpc_peering_connection[count.index], "accepter_vpc_id", null)
460-
vpc_id = aws_vpc.main.0.id
461-
peer_region = lookup(var.vpc_peering_connection[count.index], "accepter_vpc_region", null)
462-
463-
tags = var.default_tags
464-
}
465-
resource "aws_vpc_peering_connection_accepter" "main" {
466-
count = var.create ? length(var.vpc_peering_connection) : 0
467-
468-
vpc_peering_connection_id = aws_vpc_peering_connection.main.0.id
469-
auto_accept = lookup(var.vpc_peering_connection[count.index], "auto_accept", null )
470-
471-
tags = var.default_tags
472-
}
473-
474-
## VPN
475-
476-
resource "aws_vpn_gateway" "main" {
477-
count = var.create ? length(var.vpn_customer_gateway) : 0
478-
479-
depends_on = [ aws_vpc.main ]
480-
481-
vpc_id = aws_vpc.main.0.id
482-
483-
tags = var.default_tags
484-
}
485-
486-
resource "aws_customer_gateway" "main" {
487-
count = var.create ? length(var.vpn_customer_gateway) : 0
488-
489-
depends_on = [ aws_vpc.main ]
490-
491-
bgp_asn = lookup(var.vpn_customer_gateway[count.index], "bgp_asn", null)
492-
ip_address = lookup(var.vpn_customer_gateway[count.index], "ip_address", null)
493-
type = lookup(var.vpn_customer_gateway[count.index], "type", null)
494-
495-
tags = var.default_tags
496-
}
497-
498-
resource "aws_vpn_connection" "main" {
499-
count = var.create ? length(var.vpn_customer_gateway) : 0
500-
501-
depends_on = [ aws_vpc.main, aws_customer_gateway.main, aws_vpn_gateway.main ]
502-
503-
vpn_gateway_id = aws_vpn_gateway.main.0.id
504-
customer_gateway_id = aws_customer_gateway.main.0.id
505-
type = lookup(var.vpn_customer_gateway[count.index], "type", null)
506-
static_routes_only = lookup(var.vpn_customer_gateway[count.index], "static_routes_only", null)
507-
508-
tags = var.default_tags
509-
}
510-
511-
512-
## VPC Endpoint
513-
514-
resource "aws_vpc_endpoint" "main" {
515-
count = var.create ? length(var.vpc_endpoint) : 0
516-
517-
epends_on = [ aws_vpc.main ]
518-
519-
vpc_id = aws_vpc.main.0.id
520-
service_name = lookup(var.vpc_endpoint[count.index], "service_name", null)
521-
vpc_endpoint_type = lookup(var.vpc_endpoint[count.index], "endpoint_type", null)
522-
private_dns_enabled = lookup(var.vpc_endpoint[count.index], "private_dns_enabled", "false")
523-
524-
route_table_ids = [ aws_route_table.private.*.id, aws_route_table.public.*.id ]
525-
526-
tags = merge({
527-
Name = "${var.vpc_name}-VPC_EP"
528-
}, var.default_tags)
529451
}

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ variable "vpn_customer_gateway" {
8585
type = any
8686
default = []
8787
}
88+
variable "vpc_endpoint" {
89+
type = any
90+
default = []
91+
}

vpc_endpoint.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## VPC Endpoint
2+
3+
resource "aws_vpc_endpoint" "main" {
4+
count = var.create ? length(var.vpc_endpoint) : 0
5+
6+
epends_on = [ aws_vpc.main ]
7+
8+
vpc_id = aws_vpc.main.0.id
9+
service_name = lookup(var.vpc_endpoint[count.index], "service_name", null)
10+
vpc_endpoint_type = lookup(var.vpc_endpoint[count.index], "endpoint_type", null)
11+
private_dns_enabled = lookup(var.vpc_endpoint[count.index], "private_dns_enabled", "false")
12+
13+
route_table_ids = [ aws_route_table.private.*.id, aws_route_table.public.*.id ]
14+
15+
tags = merge({
16+
Name = "${var.vpc_name}-VPC_EP"
17+
}, var.default_tags)
18+
}

vpc_peering.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## VPC Peering
2+
resource "aws_vpc_peering_connection" "main" {
3+
count = var.create ? length(var.vpc_peering_connection) : 0
4+
5+
depends_on = [ aws_vpc.main ]
6+
7+
peer_vpc_id = lookup(var.vpc_peering_connection[count.index], "accepter_vpc_id", null)
8+
vpc_id = aws_vpc.main.0.id
9+
peer_region = lookup(var.vpc_peering_connection[count.index], "accepter_vpc_region", null)
10+
11+
tags = var.default_tags
12+
}
13+
resource "aws_vpc_peering_connection_accepter" "main" {
14+
count = var.create ? length(var.vpc_peering_connection) : 0
15+
16+
vpc_peering_connection_id = aws_vpc_peering_connection.main.0.id
17+
auto_accept = lookup(var.vpc_peering_connection[count.index], "auto_accept", null )
18+
19+
tags = var.default_tags
20+
}

vpc_vpn_gateway.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## VPN
2+
3+
resource "aws_vpn_gateway" "main" {
4+
count = var.create ? length(var.vpn_customer_gateway) : 0
5+
6+
depends_on = [ aws_vpc.main ]
7+
8+
vpc_id = aws_vpc.main.0.id
9+
10+
tags = var.default_tags
11+
}
12+
13+
resource "aws_customer_gateway" "main" {
14+
count = var.create ? length(var.vpn_customer_gateway) : 0
15+
16+
depends_on = [ aws_vpc.main ]
17+
18+
bgp_asn = lookup(var.vpn_customer_gateway[count.index], "bgp_asn", null)
19+
ip_address = lookup(var.vpn_customer_gateway[count.index], "ip_address", null)
20+
type = lookup(var.vpn_customer_gateway[count.index], "type", null)
21+
22+
tags = var.default_tags
23+
}
24+
25+
resource "aws_vpn_connection" "main" {
26+
count = var.create ? length(var.vpn_customer_gateway) : 0
27+
28+
depends_on = [ aws_vpc.main, aws_customer_gateway.main, aws_vpn_gateway.main ]
29+
30+
vpn_gateway_id = aws_vpn_gateway.main.0.id
31+
customer_gateway_id = aws_customer_gateway.main.0.id
32+
type = lookup(var.vpn_customer_gateway[count.index], "type", null)
33+
static_routes_only = lookup(var.vpn_customer_gateway[count.index], "static_routes_only", null)
34+
35+
tags = var.default_tags
36+
}

0 commit comments

Comments
 (0)