# vpc-peering

Creates VPC peering connections with automatic accepter wiring and route table updates.

Provisions VPC peering connections (same-account intra-region, cross-account, or cross-region), accepts same-account connections automatically, and installs routes in both the requester and accepter route tables. Cross-account and cross-region acceptance must be performed via a provider alias in the calling stack.

## Usage

```hcl
module "vpc_peering" {
  source  = "hcassc.jfrog.io/iac-terraform-modules-virtual/networking/vpc-peering/aws"
  version = "0.1.0"

  peering_connections = {
    prod_to_shared = {
      requester_vpc_id       = module.prod_vpc.id
      peer_vpc_id            = module.shared_vpc.id
      requester_cidr         = "10.0.0.0/16"
      accepter_cidr          = "10.1.0.0/16"
      requester_route_tables = values(module.prod_vpc.private_route_table_ids)
      accepter_route_tables  = values(module.shared_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_route.accepter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
| [aws_route.requester](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
| [aws_vpc_peering_connection.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_peering_connection) | resource |
| [aws_vpc_peering_connection_accepter.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_peering_connection_accepter) | resource |

## Inputs

| Name | Description | Type | Default | Required |
| ---- | ----------- | ---- | ------- | :------: |
| <a name="input_peering_connections"></a> [peering_connections](#input_peering_connections) | Map of VPC peering connections. peer_vpc_id is the accepter VPC.<br/>peer_account_id and peer_region are required for cross-account / cross-region peering.<br/>auto_accept requires both VPCs in the same account and region. | <pre>map(object({<br/>    requester_vpc_id       = string<br/>    peer_vpc_id            = string<br/>    peer_account_id        = optional(string, null)<br/>    peer_region            = optional(string, null)<br/>    auto_accept            = optional(bool, false)<br/>    allow_remote_vpc_dns   = optional(bool, true)<br/>    requester_route_tables = optional(list(string), [])<br/>    accepter_route_tables  = optional(list(string), [])<br/>    requester_cidr         = optional(string, null)<br/>    accepter_cidr          = optional(string, null)<br/>  }))</pre> | `{}` | no |
| <a name="input_tags"></a> [tags](#input_tags) | Resource tags to apply to all resources | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
| ---- | ----------- |
| <a name="output_connection_ids"></a> [connection_ids](#output_connection_ids) | Map of peering connection logical key to connection ID |
| <a name="output_connection_statuses"></a> [connection_statuses](#output_connection_statuses) | Map of peering connection logical key to status |
<!-- END_TF_DOCS — DO NOT EDIT ABOVE THIS LINE -->
