Skip to content

Commit

Permalink
CORE-2711 - fix variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonmfr committed Dec 8, 2023
1 parent 0e84f98 commit 7af3cdf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ No modules.
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
| <a name="input_tgw_association_default_route_table_id"></a> [tgw\_association\_default\_route\_table\_id](#input\_tgw\_association\_default\_route\_table\_id) | Existing Transit Gateway Route Table ID to use instead of creating a new one | `string` | `"tgw-rtb-0e2771324a8b5ccbc"` | no |
| <a name="input_tgw_default_route_table_tags"></a> [tgw\_default\_route\_table\_tags](#input\_tgw\_default\_route\_table\_tags) | Additional tags for the Default TGW route table | `map(string)` | `{}` | no |
| <a name="input_tgw_peering_attachments"></a> [tgw\_peering\_attachments](#input\_tgw\_peering\_attachments) | A map of transit gateway peering attachments | <pre>map(object({<br> peeer_acceptor_tgw_id = string<br> peer_region = string<br> peer_account_id = string<br> request_acceptor = bool<br> }))</pre> | `{}` | no |
| <a name="input_tgw_peering_attachments"></a> [tgw\_peering\_attachments](#input\_tgw\_peering\_attachments) | A map of transit gateway peering attachments | <pre>map(object({<br> peer_acceptor_tgw_id = string<br> peer_region = string<br> peer_account_id = string<br> request_acceptor = bool<br> }))</pre> | `{}` | no |
| <a name="input_tgw_peering_route_table_routes"></a> [tgw\_peering\_route\_table\_routes](#input\_tgw\_peering\_route\_table\_routes) | A list of routes for the Transit Gateway Peering Route Table | <pre>list(object({<br> destination_cidr_block = string<br> peering_attachment_key = string<br> }))</pre> | `[]` | no |
| <a name="input_tgw_route_table_tags"></a> [tgw\_route\_table\_tags](#input\_tgw\_route\_table\_tags) | Additional tags for the TGW route table | `map(string)` | `{}` | no |
| <a name="input_tgw_tags"></a> [tgw\_tags](#input\_tgw\_tags) | Additional tags for the TGW | `map(string)` | `{}` | no |
Expand Down
21 changes: 14 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
locals {
enable_peering = var.enable_peering && !var.create_tgw

tgw_default_route_table_tags_merged = merge(
tags = merge(
var.tags,
{
Module = "terraform-aws-transit-gateway"
}
)

tgw_default_route_table_tags_merged = merge(
local.tags,
{ Name = var.name },
var.tgw_default_route_table_tags,
)
Expand Down Expand Up @@ -53,7 +60,7 @@ resource "aws_ec2_transit_gateway" "this" {
}

tags = merge(
var.tags,
local.tags,
{ Name = var.name },
var.tgw_tags,
)
Expand Down Expand Up @@ -85,7 +92,7 @@ resource "aws_ec2_transit_gateway_vpc_attachment" "this" {
vpc_id = each.value.vpc_id

tags = merge(
var.tags,
local.tags,
{ Name = var.name },
var.tgw_vpc_attachment_tags,
try(each.value.tags, {}),
Expand All @@ -102,7 +109,7 @@ resource "aws_ec2_transit_gateway_route_table" "this" {
transit_gateway_id = aws_ec2_transit_gateway.this[0].id

tags = merge(
var.tags,
local.tags,
{ Name = var.name },
var.tgw_route_table_tags,
)
Expand Down Expand Up @@ -168,7 +175,7 @@ resource "aws_ram_resource_share" "this" {
name = coalesce(var.ram_name, var.name)

tags = merge(
var.tags,
local.tags,
{ Name = coalesce(var.ram_name, var.name) },
var.ram_tags,
)
Expand All @@ -190,11 +197,11 @@ resource "aws_ec2_transit_gateway_peering_attachment" "this" {

peer_account_id = each.value.peer_account_id
peer_region = each.value.peer_region
peer_transit_gateway_id = each.value.peeer_acceptor_tgw_id
peer_transit_gateway_id = each.value.peer_acceptor_tgw_id
transit_gateway_id = var.peer_requester_tgw_id

tags = merge(
var.tags,
local.tags,
{ Name = "peering-${each.value.peer_region}" }
)

Expand Down
34 changes: 18 additions & 16 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
################################################################################
# Common
################################################################################
variable "name" {
description = "Name to be used on all the resources as identifier"
type = string
default = ""
}

variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}
################################################################################
# TGW Peering Settings
################################################################################
variable "peer_requester_tgw_id" {
Expand All @@ -13,19 +27,14 @@ variable "tgw_association_default_route_table_id" {
default = "tgw-rtb-0e2771324a8b5ccbc"
}

variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

variable "tgw_peering_attachments" {
description = "A map of transit gateway peering attachments"
type = map(object({
peeer_acceptor_tgw_id = string
peer_region = string
peer_account_id = string
request_acceptor = bool
peer_acceptor_tgw_id = string
peer_region = string
peer_account_id = string
request_acceptor = bool
}))
default = {}
}
Expand All @@ -45,13 +54,6 @@ variable "enable_peering" {
default = false
}

variable "name" {
description = "Name to be used on all the resources as identifier"
type = string
default = ""
}


################################################################################
# Transit Gateway
################################################################################
Expand Down

0 comments on commit 7af3cdf

Please sign in to comment.