# tgw-attachment

Attaches a spoke VPC to a Transit Gateway and wires up route propagation and VPC route table entries.

Creates a TGW VPC attachment in the specified subnets, optionally associates and propagates routes to/from a specific TGW route table (falling back to the default), and installs TGW routes in each supplied VPC route table. Run in the spoke account. Depends on the `networking/transit-gateway` module in the network account for the TGW ID (shared via RAM).

## Usage

```hcl
module "tgw_attachment" {
  source  = "hcassc.jfrog.io/iac-terraform-modules-virtual/networking/tgw-attachment/aws"
  version = "0.1.0"

  name               = "prod-vpc-attachment"
  transit_gateway_id = data.aws_ec2_transit_gateway.core.id
  vpc_id             = module.vpc.id
  subnet_ids         = module.vpc.private_subnet_id_list
  vpc_route_table_ids = values(module.vpc.private_route_table_ids)
}
```

<!-- BEGIN_TF_DOCS — DO NOT EDIT BELOW THIS LINE -->
## Requirements

| Name | Version |
| ---- | ------- |
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | ~> 1.5 |
| <a name="requirement_aws"></a> [aws](#requirement_aws) | ~> 6.50 |

## Providers

| Name | Version |
| ---- | ------- |
| <a name="provider_aws"></a> [aws](#provider_aws) | 6.50.0 |

## Resources

| Name | Type |
| ---- | ---- |
| [aws_ec2_transit_gateway_route_table_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_association) | resource |
| [aws_ec2_transit_gateway_route_table_propagation.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_propagation) | resource |
| [aws_ec2_transit_gateway_vpc_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_vpc_attachment) | resource |
| [aws_route.tgw](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |

## Inputs

| Name | Description | Type | Default | Required |
| ---- | ----------- | ---- | ------- | :------: |
| <a name="input_name"></a> [name](#input_name) | Name for the TGW attachment | `string` | n/a | yes |
| <a name="input_subnet_ids"></a> [subnet_ids](#input_subnet_ids) | List of subnet IDs (one per AZ) for the TGW attachment ENIs | `list(string)` | n/a | yes |
| <a name="input_transit_gateway_id"></a> [transit_gateway_id](#input_transit_gateway_id) | ID of the Transit Gateway to attach to | `string` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc_id](#input_vpc_id) | ID of the VPC to attach | `string` | n/a | yes |
| <a name="input_appliance_mode_support"></a> [appliance_mode_support](#input_appliance_mode_support) | Enable appliance mode (required for stateful appliances) | `string` | `"disable"` | no |
| <a name="input_dns_support"></a> [dns_support](#input_dns_support) | DNS support for the attachment | `string` | `"enable"` | no |
| <a name="input_ipv6_support"></a> [ipv6_support](#input_ipv6_support) | IPv6 support for the attachment | `string` | `"disable"` | no |
| <a name="input_tags"></a> [tags](#input_tags) | Resource tags to apply to all resources | `map(string)` | `{}` | no |
| <a name="input_transit_gateway_route_table_id"></a> [transit_gateway_route_table_id](#input_transit_gateway_route_table_id) | TGW route table ID to associate and propagate (optional — uses default when null) | `string` | `null` | no |
| <a name="input_vpc_route_table_ids"></a> [vpc_route_table_ids](#input_vpc_route_table_ids) | VPC route table IDs to add TGW routes to | `list(string)` | `[]` | no |
| <a name="input_vpc_tgw_routes"></a> [vpc_tgw_routes](#input_vpc_tgw_routes) | Map of CIDR destinations to add as TGW routes in vpc_route_table_ids | `map(string)` | <pre>{<br/>  "0.0.0.0/0": "tgw"<br/>}</pre> | no |

## Outputs

| Name | Description |
| ---- | ----------- |
| <a name="output_arn"></a> [arn](#output_arn) | TGW VPC attachment ARN |
| <a name="output_id"></a> [id](#output_id) | TGW VPC attachment ID |
<!-- END_TF_DOCS — DO NOT EDIT ABOVE THIS LINE -->
