Skip to main content

VPC peering

The module allows to create VPC peering between two networks in both directions.

By default, no routes are exported/imported for each direction, every option has to be explicitely enabled by setting appropriate value to true.

GitHub Logo Terraform Logo

Reference

Requirements

  • terraform, version: >= 1.3, < 2.0
  • google, version: >= 4.54

Providers

  • google, version: >= 4.54

Resources

  • compute_network_peering (managed)
  • compute_network_peering (managed)

Required Inputs

NameTypeDescription
local_networkstringSelf-link or id of the first network (local) in pair.
peer_networkstringSelf-link or id of the second network (peer) in pair.

Optional Inputs

NameTypeDescription
local_peering_namestringName for 'local->peer' direction peering resource.
peer_peering_namestringName for 'peer->local' direction peering resource.
name_prefixstringOptional prefix for auto-generated peering resource names.
stack_typestringWhich IP version(s) or routes are allowed to be imported or exported between peer networks.
local_export_custom_routesboolExport custom routes setting for 'local->peer' direction.
local_import_custom_routesboolImport custom routes setting for 'local->peer' direction.
local_export_subnet_routes_with_public_ipboolExport subnet routes with public IP setting for 'local->peer' direction.
local_import_subnet_routes_with_public_ipboolImport subnet routes with public IP setting for 'local->peer' direction.
peer_export_custom_routesboolExport custom routes setting for 'peer->local' direction.
peer_import_custom_routesboolImport custom routes setting for 'peer->local' direction.
peer_export_subnet_routes_with_public_ipboolExport subnet routes with public IP setting for 'peer->local' direction.
peer_import_subnet_routes_with_public_ipboolImport subnet routes with public IP setting for 'peer->local' direction.

Required Inputs details

local_network

Self-link or id of the first network (local) in pair.

Type: string

back to list

peer_network

Self-link or id of the second network (peer) in pair.

Type: string

back to list

Optional Inputs details

local_peering_name

Name for 'local->peer' direction peering resource. If not specified defaults to <name_prefix><local network name>-<peer network name>.

Type: string

Default value: &{}

back to list

peer_peering_name

Name for 'peer->local' direction peering resource. If not specified defaults to <name_prefix><peer network name>-<local network name>.

Type: string

Default value: &{}

back to list

name_prefix

Optional prefix for auto-generated peering resource names.

Type: string

Default value: ``

back to list

stack_type

Which IP version(s) or routes are allowed to be imported or exported between peer networks. Possible values: IPV4_ONLY (default), IPV4_IPV6.

Type: string

Default value: &{}

back to list

local_export_custom_routes

Export custom routes setting for 'local->peer' direction.

Type: bool

Default value: false

back to list

local_import_custom_routes

Import custom routes setting for 'local->peer' direction.

Type: bool

Default value: false

back to list

local_export_subnet_routes_with_public_ip

Export subnet routes with public IP setting for 'local->peer' direction.

Type: bool

Default value: false

back to list

local_import_subnet_routes_with_public_ip

Import subnet routes with public IP setting for 'local->peer' direction.

Type: bool

Default value: false

back to list

peer_export_custom_routes

Export custom routes setting for 'peer->local' direction.

Type: bool

Default value: false

back to list

peer_import_custom_routes

Import custom routes setting for 'peer->local' direction.

Type: bool

Default value: false

back to list

peer_export_subnet_routes_with_public_ip

Export subnet routes with public IP setting for 'peer->local' direction.

Type: bool

Default value: false

back to list

peer_import_subnet_routes_with_public_ip

Import subnet routes with public IP setting for 'peer->local' direction.

Type: bool

Default value: false

back to list