Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
feat(module/transit_gateway): add TGW cidr blocks (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
lstadnik authored Jan 4, 2024
1 parent 32911fc commit 32383dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/transit_gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ No modules.
| <a name="input_route_tables"></a> [route\_tables](#input\_route\_tables) | n/a | `map` | `{}` | no |
| <a name="input_shared_principals"></a> [shared\_principals](#input\_shared\_principals) | n/a | `map` | `{}` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Optional Map of arbitrary tags to apply to all resources | `map(string)` | `{}` | no |
| <a name="input_transit_gateway_cidr_blocks"></a> [transit\_gateway\_cidr\_blocks](#input\_transit\_gateway\_cidr\_blocks) | One or more IPv4 or IPv6 CIDR blocks for the transit gateway. Must be a size /24 CIDR block or larger for IPv4, or a size /64 CIDR block or larger for IPv6. | `set(string)` | `[]` | no |
| <a name="input_vpn_ecmp_support"></a> [vpn\_ecmp\_support](#input\_vpn\_ecmp\_support) | See the [provider documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway). | `string` | `null` | no |

### Outputs
Expand Down
1 change: 1 addition & 0 deletions modules/transit_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "aws_ec2_transit_gateway" "this" {
auto_accept_shared_attachments = var.auto_accept_shared_attachments
default_route_table_association = "disable"
default_route_table_propagation = "disable"
transit_gateway_cidr_blocks = var.transit_gateway_cidr_blocks
dns_support = var.dns_support
vpn_ecmp_support = var.vpn_ecmp_support
tags = merge(var.tags, { Name = var.name })
Expand Down
10 changes: 10 additions & 0 deletions modules/transit_gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ variable "shared_principals" {
default = {}
}

variable "transit_gateway_cidr_blocks" {
description = "One or more IPv4 or IPv6 CIDR blocks for the transit gateway. Must be a size /24 CIDR block or larger for IPv4, or a size /64 CIDR block or larger for IPv6."
default = []
type = set(string)
validation {
condition = alltrue([for cidr in var.transit_gateway_cidr_blocks : can(cidrsubnet(cidr, 0, 0))])
error_message = "Transit gateway CIDR blocks must contain valid IPv4 or IPv6 CIDR."
}
}

variable "tags" {
description = "Optional Map of arbitrary tags to apply to all resources"
type = map(string)
Expand Down

0 comments on commit 32383dc

Please sign in to comment.