hub-connector
This component is responsible for provisioning an AWS Transit Gateway Peering Connection to connect TGWs from different accounts and(or) regions.
Transit Gateway does not support sharing the Transit Gateway hub across regions. You must deploy a Transit Gateway hub for each region and connect the alternate hub to the primary hub.
Usage
Stack Level: Regional
This component is deployed to each alternate region with tgw/hub
.
For example if your primary region is us-east-1
and your alternate region is us-west-2
, deploy another tgw/hub
in
us-west-2
and peer the two with tgw/cross-region-hub-connector
with the following stack config, imported into
us-west-2
import:
- catalog/tgw/hub
components:
terraform:
# Cross region TGW requires additional hub in the alternate region
tgw/hub:
vars:
# These are all connections available for spokes in this region
# Defaults environment to this region
connections:
# Hub for this region is always required
- account:
tenant: core
stage: network
# VPN source
- account:
tenant: core
stage: network
environment: use1
# Github Runners
- account:
tenant: core
stage: auto
environment: use1
eks_component_names:
- eks/cluster
# All stacks where a spoke will be deployed
- account:
tenant: plat
stage: dev
eks_component_names: [] # Add clusters here once deployed
# This alternate hub needs to be connected to the primary region's hub
tgw/cross-region-hub-connector:
vars:
enabled: true
primary_tgw_hub_region: us-east-1
Variables
Required Variables
primary_tgw_hub_region
(string
) requiredThe name of the AWS region where the primary Transit Gateway hub is deployed. This value is used with
var.env_naming_convention
to determine the primary Transit Gateway hub's environment name.region
(string
) requiredAWS Region
Optional Variables
account_map_environment_name
(string
) optionalThe name of the environment where
account_map
is provisionedDefault value:
"gbl"
account_map_stage_name
(string
) optionalThe name of the stage where
account_map
is provisionedDefault value:
"root"
account_map_tenant_name
(string
) optionalThe name of the tenant where
account_map
is provisionedDefault value:
"core"
env_naming_convention
(string
) optionalThe cloudposse/utils naming convention used to translate environment name to AWS region name. Options are
to_short
andto_fixed
Default value:
"to_short"
primary_tgw_hub_stage
(string
) optionalThe name of the stage where the primary Transit Gateway hub is deployed. Defaults to
module.this.stage
Default value:
""
primary_tgw_hub_tenant
(string
) optionalThe name of the tenant where the primary Transit Gateway hub is deployed. Only used if tenants are deployed and defaults to
module.this.tenant
Default value:
""
Context Variables
The following variables are defined in the context.tf
file of this module and part of the terraform-null-label pattern.
context.tf
file of this module and part of the terraform-null-label pattern.Outputs
aws_ec2_transit_gateway_peering_attachment_id
Transit Gateway Peering Attachment ID
Dependencies
Requirements
terraform
, version:>= 1.0.0
aws
, version:>= 4.1
utils
, version:>= 1.10.0
Providers
aws
, version:>= 4.1
aws
, version:>= 4.1
utils
, version:>= 1.10.0
Modules
Name | Version | Source | Description |
---|---|---|---|
account_map | 1.8.0 | cloudposse/stack-config/yaml//modules/remote-state | n/a |
iam_roles | latest | ../../account-map/modules/iam-roles | n/a |
tgw_hub_primary_region | 1.8.0 | cloudposse/stack-config/yaml//modules/remote-state | n/a |
tgw_hub_this_region | 1.8.0 | cloudposse/stack-config/yaml//modules/remote-state | n/a |
this | 0.25.0 | cloudposse/label/null | n/a |
utils | 1.4.0 | cloudposse/utils/aws | Used to translate region to environment |
Resources
The following resources are used by this module:
aws_ec2_transit_gateway_peering_attachment.this
(resource)aws_ec2_transit_gateway_peering_attachment_accepter.primary_region
(resource)aws_ec2_transit_gateway_route_table_association.primary_region
(resource)aws_ec2_transit_gateway_route_table_association.this_region
(resource)
Data Sources
The following data sources are used by this module:
utils_component_config.primary_tgw_hub
(data source)
References
- cloudposse/terraform-aws-components - Cloud Posse's upstream component