Skip to content

Commit 4cb41bd

Browse files
authored
Ahaffar/v1.0.6 (#4)
* Transit GW - Adding the feature to create routes with a destination of tgw (if provided) * Fixing resource names * Adding more outputs to vpc module * Adding more outputs to vpc module * Adding more outputs to vpc module
1 parent b2c27c6 commit 4cb41bd

File tree

7 files changed

+52
-4
lines changed

7 files changed

+52
-4
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.48.0
3+
rev: v1.72.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs
77
- id: terraform_tflint
88
- repo: git://github.com/pre-commit/pre-commit-hooks
9-
rev: v2.4.0
9+
rev: v4.2.0
1010
hooks:
1111
- id: check-merge-conflict
1212
- id: end-of-file-fixer

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Below is an example how to call and use the module, kindly check the example fol
1313

1414
```hcl
1515
module "example1" {
16-
source = "github.com/obytes/terraform-aws-vpc.git?ref=v1.0.3"
16+
source = "github.com/obytes/terraform-aws-vpc.git?ref=v1.0.6"
1717
environment = "qa"
1818
project_name = "on-cost"
1919
region = "eu-west-2"
@@ -186,4 +186,5 @@ A shortcode of the availability group will be appended to the subnet name
186186
| <a name="output_vpc_cidr_block"></a> [vpc\_cidr\_block](#output\_vpc\_cidr\_block) | CIDR Block of the VPC |
187187
| <a name="output_vpc_dhcp_dns_list"></a> [vpc\_dhcp\_dns\_list](#output\_vpc\_dhcp\_dns\_list) | n/a |
188188
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | VPC ID |
189-
| <a name="output_vpc_sg_id"></a> [vpc\_sg\_id](#output\_vpc\_sg\_id) | n/a |
189+
| <a name="output_vpc_sg_id"></a> [vpc\_sg\_id](#output\_vpc\_sg\_id) | Default VPC Security Group |
190+
| <a name="output_vpc_name"></a> [vpc\_name](#output\_vpc\_sg\_id) | VPC Name |

examples/output.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ output "vpc_sg_id" {
6363
output "vpc_dhcp_dns_list" {
6464
value = module.example1.vpc_dhcp_dns_list
6565
}
66+
67+
output "vpc_name" {
68+
value = module.example1.vpc_name
69+
}

output.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ output "vpc_id" {
5858
description = "VPC ID"
5959
}
6060

61+
output "vpc_name" {
62+
value = aws_vpc._.*.tags.Name
63+
description = "VPC NAME"
64+
}
65+
6166
output "vpc_sg_id" {
6267
value = aws_default_security_group._.*.id
6368
}

private-subnets.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ resource "aws_route" "private_nat_gateway" {
4545
}
4646
}
4747

48+
resource "aws_route" "transit_gw_route_private" {
49+
count = local.enabled && var.enable_nat_gateway && var.tgw_route_table_id != null ? length(var.transit_routes) : 0
50+
51+
route_table_id = element(aws_route_table.private.*.id, count.index)
52+
destination_cidr_block = element(var.transit_routes,count.index )
53+
transit_gateway_id = var.tgw_route_table_id
54+
55+
timeouts {
56+
create = var.route_create_timeout
57+
delete = var.route_delete_timeout
58+
}
59+
}
60+
4861
resource "aws_route_table_association" "private" {
4962
count = local.enabled && local.private_subnet_count > 0 ? local.private_subnet_count : 0
5063
route_table_id = element(aws_route_table.private.*.id, var.single_nat_gateway ? 0 : count.index)

public-subnets.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ resource "aws_route" "public_internet_gateway" {
4646
}
4747
}
4848

49+
resource "aws_route" "transit_gw_route_public" {
50+
count = local.enabled && var.enable_nat_gateway && var.tgw_route_table_id != null ? length(var.transit_routes) : 0
51+
52+
route_table_id = element(aws_route_table.public.*.id, count.index)
53+
destination_cidr_block = element(var.transit_routes,count.index )
54+
transit_gateway_id = var.tgw_route_table_id
55+
56+
timeouts {
57+
create = var.route_create_timeout
58+
delete = var.route_delete_timeout
59+
}
60+
}
61+
4962
resource "aws_route_table_association" "public" {
5063
count = local.enabled && local.public_subnet_count > 0 ? local.public_subnet_count : 0
5164
route_table_id = aws_route_table.public[0].id

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,15 @@ variable "vpc_dhcp_netbios_node_type" {
268268
default = null
269269
description = "(Optional) The NetBIOS node type (1, 2, 4, or 8). AWS recommends to specify 2 since broadcast and multicast are not supported in their network. For more information about these node types, see RFC 2132."
270270
}
271+
272+
variable "tgw_route_table_id" {
273+
type = string
274+
default = null
275+
description = "Transit GW route table ID to be added as a destination for the VPC route tables"
276+
}
277+
278+
variable "transit_routes" {
279+
type = list(string)
280+
default = []
281+
description = "The destination prefixes (CIDR blocks) that should be forwarded to transit gateway"
282+
}

0 commit comments

Comments
 (0)