From 980366ab67746907f0a2ee363e43134ffab49876 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Fri, 22 Nov 2019 11:32:26 -0800 Subject: [PATCH] Update network peering docs, schema --- .../resource_compute_network_peering.go.erb | 52 ++++++++++--------- .../r/compute_network_peering.html.markdown | 19 +++++-- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/third_party/terraform/resources/resource_compute_network_peering.go.erb b/third_party/terraform/resources/resource_compute_network_peering.go.erb index f0f809ac8ccf..6785c064f095 100644 --- a/third_party/terraform/resources/resource_compute_network_peering.go.erb +++ b/third_party/terraform/resources/resource_compute_network_peering.go.erb @@ -27,6 +27,7 @@ func resourceComputeNetworkPeering() *schema.Resource { ForceNew: true, ValidateFunc: validateGCPName, }, + "network": { Type: schema.TypeString, Required: true, @@ -34,6 +35,7 @@ func resourceComputeNetworkPeering() *schema.Resource { ValidateFunc: validateRegexp(peerNetworkLinkRegex), DiffSuppressFunc: compareSelfLinkRelativePaths, }, + "peer_network": { Type: schema.TypeString, Required: true, @@ -41,22 +43,7 @@ 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, - }, + <% unless version == 'ga' -%> "export_custom_routes": { Type: schema.TypeBool, @@ -64,6 +51,7 @@ func resourceComputeNetworkPeering() *schema.Resource { Optional: true, Default: false, }, + "import_custom_routes": { Type: schema.TypeBool, ForceNew: true, @@ -71,6 +59,23 @@ func resourceComputeNetworkPeering() *schema.Resource { Default: false, }, <% end -%> + + "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, + }, }, } } @@ -183,14 +188,13 @@ func findPeeringFromNetwork(network *computeBeta.Network, peeringName string) *c } func expandNetworkPeering(d *schema.ResourceData) *computeBeta.NetworkPeering { return &computeBeta.NetworkPeering{ - <% unless version == 'ga' -%> - ExportCustomRoutes: d.Get("export_custom_routes").(bool), - ImportCustomRoutes: d.Get("import_custom_routes").(bool), - <% end -%> - // 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), + ExchangeSubnetRoutes: true, + Name: d.Get("name").(string), + Network: d.Get("peer_network").(string), +<% unless version == 'ga' -%> + ExportCustomRoutes: d.Get("export_custom_routes").(bool), + ImportCustomRoutes: d.Get("import_custom_routes").(bool), +<% end -%> } } diff --git a/third_party/terraform/website/docs/r/compute_network_peering.html.markdown b/third_party/terraform/website/docs/r/compute_network_peering.html.markdown index 3357a38aedcf..f6cf5de7a210 100644 --- a/third_party/terraform/website/docs/r/compute_network_peering.html.markdown +++ b/third_party/terraform/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) Whether to export the custom routes to the +peer network. Defaults to `false`. + +* `import_custom_routes` - (Optional) 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.