From c2e94bc894f4abf0116bf9557c03d4a9b400c5f5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 25 Nov 2019 08:41:47 -0800 Subject: [PATCH] Update network peering docs, schema (#4982) Signed-off-by: Modular Magician --- google/resource_compute_network_peering.go | 20 ++++++++++--------- .../r/compute_network_peering.html.markdown | 19 +++++++++++++----- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/google/resource_compute_network_peering.go b/google/resource_compute_network_peering.go index c5107683868..0dd4e0a6f3e 100644 --- a/google/resource_compute_network_peering.go +++ b/google/resource_compute_network_peering.go @@ -26,6 +26,7 @@ func resourceComputeNetworkPeering() *schema.Resource { ForceNew: true, ValidateFunc: validateGCPName, }, + "network": { Type: schema.TypeString, Required: true, @@ -33,6 +34,7 @@ func resourceComputeNetworkPeering() *schema.Resource { ValidateFunc: validateRegexp(peerNetworkLinkRegex), DiffSuppressFunc: compareSelfLinkRelativePaths, }, + "peer_network": { Type: schema.TypeString, Required: true, @@ -40,22 +42,23 @@ func resourceComputeNetworkPeering() *schema.Resource { ValidateFunc: validateRegexp(peerNetworkLinkRegex), DiffSuppressFunc: compareSelfLinkRelativePaths, }, - // The API only accepts true as a value for exchange_subnet_routes or auto_create_routes (of which only one can be set in a valid request). - // Also, you can't set auto_create_routes if you use the networkPeering object. auto_create_routes is also removed - "auto_create_routes": { - Type: schema.TypeBool, - Optional: true, - Removed: "auto_create_routes has been removed because it's redundant and not user-configurable. It can safely be removed from your config", - ForceNew: true, - }, + "state": { Type: schema.TypeString, Computed: true, }, + "state_details": { Type: schema.TypeString, Computed: true, }, + + "auto_create_routes": { + Type: schema.TypeBool, + Optional: true, + Removed: "auto_create_routes has been removed because it's redundant and not user-configurable. It can safely be removed from your config", + ForceNew: true, + }, }, } } @@ -164,7 +167,6 @@ func findPeeringFromNetwork(network *computeBeta.Network, peeringName string) *c } func expandNetworkPeering(d *schema.ResourceData) *computeBeta.NetworkPeering { return &computeBeta.NetworkPeering{ - // auto_create_routes was replaced by exchange_subnet_routes in the network peering object ExchangeSubnetRoutes: true, Name: d.Get("name").(string), Network: d.Get("peer_network").(string), diff --git a/website/docs/r/compute_network_peering.html.markdown b/website/docs/r/compute_network_peering.html.markdown index 3357a38aedc..21d2317629f 100644 --- a/website/docs/r/compute_network_peering.html.markdown +++ b/website/docs/r/compute_network_peering.html.markdown @@ -14,9 +14,10 @@ Manages a network peering within GCE. For more information see and [API](https://cloud.google.com/compute/docs/reference/latest/networks). -~> **Note:** Both network must create a peering with each other for the peering to be functional. +-> Both network must create a peering with each other for the peering +to be functional. -~> **Note:** Subnets IP ranges across peered VPC networks cannot overlap. +~> Subnets IP ranges across peered VPC networks cannot overlap. ## Example Usage @@ -50,15 +51,23 @@ The following arguments are supported: * `name` - (Required) Name of the peering. -* `network` - (Required) Resource link of the network to add a peering to. +* `network` - (Required) The primary network of the peering. -* `peer_network` - (Required) Resource link of the peer network. +* `peer_network` - (Required) The peer network in the peering. The peer network +may belong to a different project. + +* `export_custom_routes` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) +Whether to export the custom routes to the peer network. Defaults to `false`. + +* `import_custom_routes` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) +Whether to export the custom routes from the peer network. Defaults to `false`. ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: -* `state` - State for the peering. +* `state` - State for the peering, either `ACTIVE` or `INACTIVE`. The peering is +`ACTIVE` when there's a matching configuration in the peer network. * `state_details` - Details about the current state of the peering.