Skip to content

Commit

Permalink
Merge pull request #374 from lorengordon/feat/peering-enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
lorengordon authored Aug 20, 2024
2 parents 904f2f4 + 4bd8502 commit 35ae800
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.2.0
current_version = 2.3.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
23 changes: 12 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,32 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### 2.2.0
### [2.3.0](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/releases/tag/2.3.0)

**Commit Delta**: [Change from 2.1.0 release](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/compare/2.1.0..2.2.0)
**Released**: 2024.08.20

**Summary**:

* Manages tgw route table associations for tgw peering connections
* Supports `options` input for peering attachment resource

### [2.2.0](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/releases/tag/2.2.0)

**Released**: 2023.07.18

**Summary**:

* Supports auto-accept configurations for cross-account vpc attachments

### 2.1.0

**Commit Delta**: [Change from 2.0.0 release](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/compare/2.0.0..2.1.0)
### [2.1.0](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/releases/tag/2.1.0)

**Released**: 2022.03.29

**Summary**:

* Supports creating VPC Attachments in appliance mode using the argument, `appliance_mode_support`.

### 2.0.0

**Commit Delta**: [Change from 1.0.2 release](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/compare/1.0.2..2.0.0)
### [2.0.0](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/releases/tag/2.0.0)

**Released**: 2021.12.29

Expand All @@ -39,9 +42,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
* Bumps minimum terraform version to 0.15 for the cross-account and cross-region
modules.

### 0.0.0

**Commit Delta**: N/A
### [0.0.0](https://github.com/plus3it/terraform-aws-tardigrade-transit-gateway/releases/tag/0.0.0)

**Released**: 2019.11.13

Expand Down
3 changes: 3 additions & 0 deletions modules/cross-region-peering-attachment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ No resources.
| <a name="input_peer_region"></a> [peer\_region](#input\_peer\_region) | Region of EC2 Transit Gateway to peer with | `string` | n/a | yes |
| <a name="input_peer_transit_gateway_id"></a> [peer\_transit\_gateway\_id](#input\_peer\_transit\_gateway\_id) | ID of the Transit Gateway to peer with | `string` | n/a | yes |
| <a name="input_transit_gateway_id"></a> [transit\_gateway\_id](#input\_transit\_gateway\_id) | ID of the Transit Gateway | `string` | n/a | yes |
| <a name="input_options"></a> [options](#input\_options) | Object of options for the TGW peering attachment | <pre>object({<br> dynamic_routing = optional(string)<br> })</pre> | `null` | no |
| <a name="input_peer_account_id"></a> [peer\_account\_id](#input\_peer\_account\_id) | ID of the AWS account that owns the Transit Gateway peer | `string` | `null` | no |
| <a name="input_peer_transit_gateway_route_table_association"></a> [peer\_transit\_gateway\_route\_table\_association](#input\_peer\_transit\_gateway\_route\_table\_association) | ID of the Peer Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table) | <pre>object({<br> transit_gateway_route_table_id = string<br> })</pre> | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags to apply to the TGW peering attachments | `map(string)` | `{}` | no |
| <a name="input_transit_gateway_route_table_association"></a> [transit\_gateway\_route\_table\_association](#input\_transit\_gateway\_route\_table\_association) | ID of the Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table) | <pre>object({<br> transit_gateway_route_table_id = string<br> })</pre> | `null` | no |

## Outputs

Expand Down
21 changes: 16 additions & 5 deletions modules/cross-region-peering-attachment/main.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
module "peering_attachment" {
source = "../peering-attachment"

peer_account_id = var.peer_account_id
peer_region = var.peer_region
peer_transit_gateway_id = var.peer_transit_gateway_id
transit_gateway_id = var.transit_gateway_id
tags = var.tags
peer_transit_gateway_id = var.peer_transit_gateway_id
peer_region = var.peer_region

options = var.options
peer_account_id = var.peer_account_id
tags = var.tags

# Associate the Peering attachment with a TGW route table, while establishing
# a depenency between the accepter and the association
transit_gateway_route_table_association = var.transit_gateway_route_table_association != null ? {
transit_gateway_attachment_id = module.peering_accepter.peering_attachment_accepter.id
transit_gateway_route_table_id = var.transit_gateway_route_table_association.transit_gateway_route_table_id
} : null
}

module "peering_accepter" {
source = "../peering-accepter"

providers = {
aws = aws.peer
}

peering_attachment_id = module.peering_attachment.peering_attachment.id
peering_attachment_id = module.peering_attachment.peering_attachment.id
transit_gateway_route_table_association = var.peer_transit_gateway_route_table_association

tags = var.tags
}
29 changes: 29 additions & 0 deletions modules/cross-region-peering-attachment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,37 @@ variable "peer_account_id" {
default = null
}

variable "peer_transit_gateway_route_table_association" {
description = "ID of the Peer Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table)"
type = object({
transit_gateway_route_table_id = string
})
default = null
}

variable "options" {
description = "Object of options for the TGW peering attachment"
type = object({
dynamic_routing = optional(string)
})
default = null

validation {
condition = var.options != null && try(var.options.dynamic_routing, null) != null ? contains(["enable", "disable"], var.options.dynamic_routing) : true
error_message = "`var.options.dynamic_routing` must be one of: \"enable\", \"disable\"."
}
}

variable "tags" {
description = "Map of tags to apply to the TGW peering attachments"
type = map(string)
default = {}
}

variable "transit_gateway_route_table_association" {
description = "ID of the Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table)"
type = object({
transit_gateway_route_table_id = string
})
default = null
}
1 change: 1 addition & 0 deletions modules/peering-accepter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Terraform module for managing a Transit Gateway Peering Attachment Accepter.
|------|-------------|------|---------|:--------:|
| <a name="input_peering_attachment_id"></a> [peering\_attachment\_id](#input\_peering\_attachment\_id) | ID of the TGW peering attachment | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags to apply to the TGW peering attachment | `map(string)` | `{}` | no |
| <a name="input_transit_gateway_route_table_association"></a> [transit\_gateway\_route\_table\_association](#input\_transit\_gateway\_route\_table\_association) | ID of the Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table) | <pre>object({<br> transit_gateway_route_table_id = string<br> })</pre> | `null` | no |

## Outputs

Expand Down
7 changes: 7 additions & 0 deletions modules/peering-accepter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ resource "aws_ec2_transit_gateway_peering_attachment_accepter" "this" {

tags = var.tags
}

resource "aws_ec2_transit_gateway_route_table_association" "this" {
count = var.transit_gateway_route_table_association != null ? 1 : 0

transit_gateway_attachment_id = aws_ec2_transit_gateway_peering_attachment_accepter.this.id
transit_gateway_route_table_id = var.transit_gateway_route_table_association.transit_gateway_route_table_id
}
8 changes: 8 additions & 0 deletions modules/peering-accepter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ variable "tags" {
type = map(string)
default = {}
}

variable "transit_gateway_route_table_association" {
description = "ID of the Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table)"
type = object({
transit_gateway_route_table_id = string
})
default = null
}
3 changes: 3 additions & 0 deletions modules/peering-attachment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ Terraform module for managing a Transit Gateway Peering Attachment.
| <a name="input_peer_region"></a> [peer\_region](#input\_peer\_region) | Region of EC2 Transit Gateway to peer with | `string` | n/a | yes |
| <a name="input_peer_transit_gateway_id"></a> [peer\_transit\_gateway\_id](#input\_peer\_transit\_gateway\_id) | ID of the Transit Gateway to peer with | `string` | n/a | yes |
| <a name="input_transit_gateway_id"></a> [transit\_gateway\_id](#input\_transit\_gateway\_id) | ID of the Transit Gateway | `string` | n/a | yes |
| <a name="input_options"></a> [options](#input\_options) | Object of options for the TGW peering attachment | <pre>object({<br> dynamic_routing = optional(string)<br> })</pre> | `null` | no |
| <a name="input_peer_account_id"></a> [peer\_account\_id](#input\_peer\_account\_id) | ID of the AWS account that owns the Transit Gateway peer | `string` | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags to apply to the TGW peering attachment | `map(string)` | `{}` | no |
| <a name="input_transit_gateway_route_table_association"></a> [transit\_gateway\_route\_table\_association](#input\_transit\_gateway\_route\_table\_association) | ID of the Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table) | <pre>object({<br> transit_gateway_route_table_id = string<br> })</pre> | `null` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_peering_attachment"></a> [peering\_attachment](#output\_peering\_attachment) | Object with the Transit Gateway peering attachment attributes |
| <a name="output_route_table_association"></a> [route\_table\_association](#output\_route\_table\_association) | Object with the Transit Gateway route table association attributes |

<!-- END TFDOCS -->
14 changes: 14 additions & 0 deletions modules/peering-attachment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ resource "aws_ec2_transit_gateway_peering_attachment" "this" {
peer_transit_gateway_id = var.peer_transit_gateway_id
transit_gateway_id = var.transit_gateway_id
tags = var.tags

dynamic "options" {
for_each = var.options != null ? [var.options] : []
content {
dynamic_routing = options.value.dynamic_routing
}
}
}

resource "aws_ec2_transit_gateway_route_table_association" "this" {
count = var.transit_gateway_route_table_association != null ? 1 : 0

transit_gateway_attachment_id = aws_ec2_transit_gateway_peering_attachment.this.id
transit_gateway_route_table_id = var.transit_gateway_route_table_association.transit_gateway_route_table_id
}
5 changes: 5 additions & 0 deletions modules/peering-attachment/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ output "peering_attachment" {
description = "Object with the Transit Gateway peering attachment attributes"
value = aws_ec2_transit_gateway_peering_attachment.this
}

output "route_table_association" {
description = "Object with the Transit Gateway route table association attributes"
value = var.transit_gateway_route_table_association != null ? aws_ec2_transit_gateway_route_table_association.this[0] : null
}
21 changes: 21 additions & 0 deletions modules/peering-attachment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,29 @@ variable "peer_account_id" {
default = null
}

variable "options" {
description = "Object of options for the TGW peering attachment"
type = object({
dynamic_routing = optional(string)
})
default = null

validation {
condition = var.options != null && try(var.options.dynamic_routing, null) != null ? contains(["enable", "disable"], var.options.dynamic_routing) : true
error_message = "`var.options.dynamic_routing` must be one of: \"enable\", \"disable\"."
}
}

variable "tags" {
description = "Map of tags to apply to the TGW peering attachment"
type = map(string)
default = {}
}

variable "transit_gateway_route_table_association" {
description = "ID of the Transit Gateway route table to associate with the Peering attachment (an attachment can be associated with a single TGW route table)"
type = object({
transit_gateway_route_table_id = string
})
default = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "random_string" "this" {
length = 6
upper = false
special = false
number = false
numeric = false
}

output "test_id" {
Expand Down
2 changes: 1 addition & 1 deletion tests/cross-account-vpc-attachment/prereq/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "random_string" "this" {
length = 6
upper = false
special = false
number = false
numeric = false
}

output "test_id" {
Expand Down
33 changes: 33 additions & 0 deletions tests/cross-region-peering-attachment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ module "peering_attachment" {
peer_transit_gateway_id = module.tgw_peer.transit_gateway.id
transit_gateway_id = module.tgw.transit_gateway.id

peer_transit_gateway_route_table_association = {
transit_gateway_route_table_id = module.tgw_peer.route_tables["tardigrade-testing-${local.id}"].route_table.id
}

transit_gateway_route_table_association = {
transit_gateway_route_table_id = module.tgw.route_tables["tardigrade-testing-${local.id}"].route_table.id
}

# Although the API claims suport for the dynamic routing option, it will fail
# if set to anything other than null. Leaving the option in place to match the
# API spec, and to support future updates.
options = null

tags = {
Name = "tardigrade-testing-${local.id}"
}
Expand All @@ -32,6 +45,16 @@ module "tgw" {

description = "tardigrade-tgw-${local.id}"

default_route_table_association = "disable"
default_route_table_propagation = "disable"

route_tables = [
{
name = "tardigrade-testing-${local.id}"
tags = {}
},
]

tags = {
Name = "tardigrade-testing-${local.id}"
}
Expand All @@ -45,6 +68,16 @@ module "tgw_peer" {

description = "tardigrade-tgw-${local.id}"

default_route_table_association = "disable"
default_route_table_propagation = "disable"

route_tables = [
{
name = "tardigrade-testing-${local.id}"
tags = {}
},
]

tags = {
Name = "tardigrade-testing-${local.id}"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cross-region-peering-attachment/prereq/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "random_string" "this" {
length = 6
upper = false
special = false
number = false
numeric = false
}

output "test_id" {
Expand Down
2 changes: 1 addition & 1 deletion tests/tgw/prereq/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "random_string" "this" {
length = 6
upper = false
special = false
number = false
numeric = false
}

output "test_id" {
Expand Down

0 comments on commit 35ae800

Please sign in to comment.