Skip to content

googleComputeNetworkPeeringRoutesConfig

Manage a network peering's route settings without managing the peering as a whole. This resource is primarily intended for use with GCP-generated peerings that shouldn't otherwise be managed by other tools. Deleting this resource is a no-op and the peering will not be modified.

To get more information about NetworkPeeringRoutesConfig, see:

Example Usage - Network Peering Routes Config Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkNetworkPrimary =
  new google.computeNetwork.ComputeNetwork(this, "network_primary", {
    auto_create_subnetworks: "false",
    name: "primary-network",
  });
const googleComputeNetworkNetworkSecondary =
  new google.computeNetwork.ComputeNetwork(this, "network_secondary", {
    auto_create_subnetworks: "false",
    name: "secondary-network",
  });
const googleComputeNetworkPeeringPeeringPrimary =
  new google.computeNetworkPeering.ComputeNetworkPeering(
    this,
    "peering_primary",
    {
      export_custom_routes: true,
      import_custom_routes: true,
      name: "primary-peering",
      network: googleComputeNetworkNetworkPrimary.id,
      peer_network: googleComputeNetworkNetworkSecondary.id,
    }
  );
new google.computeNetworkPeering.ComputeNetworkPeering(
  this,
  "peering_secondary",
  {
    name: "secondary-peering",
    network: googleComputeNetworkNetworkSecondary.id,
    peer_network: googleComputeNetworkNetworkPrimary.id,
  }
);
new google.computeNetworkPeeringRoutesConfig.ComputeNetworkPeeringRoutesConfig(
  this,
  "peering_primary_routes",
  {
    export_custom_routes: true,
    import_custom_routes: true,
    network: googleComputeNetworkNetworkPrimary.name,
    peering: googleComputeNetworkPeeringPeeringPrimary.name,
  }
);

Example Usage - Network Peering Routes Config Gke

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkContainerNetwork =
  new google.computeNetwork.ComputeNetwork(this, "container_network", {
    auto_create_subnetworks: false,
    name: "container-network",
  });
const googleComputeSubnetworkContainerSubnetwork =
  new google.computeSubnetwork.ComputeSubnetwork(this, "container_subnetwork", {
    ip_cidr_range: "10.0.36.0/24",
    name: "container-subnetwork",
    network: googleComputeNetworkContainerNetwork.name,
    private_ip_google_access: true,
    region: "us-central1",
    secondary_ip_range: [
      {
        ip_cidr_range: "10.0.0.0/19",
        range_name: "pod",
      },
      {
        ip_cidr_range: "10.0.32.0/22",
        range_name: "svc",
      },
    ],
  });
const googleContainerClusterPrivateCluster =
  new google.containerCluster.ContainerCluster(this, "private_cluster", {
    initial_node_count: 1,
    ip_allocation_policy: [
      {
        cluster_secondary_range_name: `\${${googleComputeSubnetworkContainerSubnetwork.secondaryIpRange.fqn}[0].range_name}`,
        services_secondary_range_name: `\${${googleComputeSubnetworkContainerSubnetwork.secondaryIpRange.fqn}[1].range_name}`,
      },
    ],
    location: "us-central1-a",
    master_authorized_networks_config: [{}],
    name: "private-cluster",
    network: googleComputeNetworkContainerNetwork.name,
    private_cluster_config: [
      {
        enable_private_endpoint: true,
        enable_private_nodes: true,
        master_ipv4_cidr_block: "10.42.0.0/28",
      },
    ],
    subnetwork: googleComputeSubnetworkContainerSubnetwork.name,
  });
new google.computeNetworkPeeringRoutesConfig.ComputeNetworkPeeringRoutesConfig(
  this,
  "peering_gke_routes",
  {
    export_custom_routes: true,
    import_custom_routes: true,
    network: googleComputeNetworkContainerNetwork.name,
    peering: `\${${googleContainerClusterPrivateCluster.privateClusterConfig.fqn}[0].peering_name}`,
  }
);

Argument Reference

The following arguments are supported:

  • peering - (Required) Name of the peering.

  • exportCustomRoutes - (Required) Whether to export the custom routes to the peer network.

  • importCustomRoutes - (Required) Whether to import the custom routes to the peer network.

  • network - (Required) The name of the primary network for the peering.


  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/global/networks/{{network}}/networkPeerings/{{peering}}

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

NetworkPeeringRoutesConfig can be imported using any of these accepted formats:

$ terraform import google_compute_network_peering_routes_config.default projects/{{project}}/global/networks/{{network}}/networkPeerings/{{peering}}
$ terraform import google_compute_network_peering_routes_config.default {{project}}/{{network}}/{{peering}}
$ terraform import google_compute_network_peering_routes_config.default {{network}}/{{peering}}

User Project Overrides

This resource supports User Project Overrides.