Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
71c3aeb
Merge pull request #1 from GoogleCloudPlatform/master
upodroid Aug 3, 2020
e1a9488
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Aug 10, 2020
51eaff6
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Aug 25, 2020
649e97c
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Sep 21, 2020
ee373cc
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Oct 3, 2020
d330773
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Oct 27, 2020
0d73e9f
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Nov 17, 2020
191a775
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Dec 15, 2020
b90d594
mark field as updatable
upodroid Jan 5, 2021
4b79149
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Jan 20, 2021
a3e1989
Merge branch 'master' of github.com:borg-land/magic-modules
upodroid Jan 26, 2021
9ffeb0b
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Jan 26, 2021
9dd54f3
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Feb 1, 2021
b917f22
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Feb 15, 2021
7b836a0
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Mar 22, 2021
aaeee0b
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Apr 13, 2021
03537b7
add HA VPN GW ds
upodroid Apr 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package google

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGoogleComputeHaVpnGateway() *schema.Resource {
dsSchema := datasourceSchemaFromResourceSchema(resourceComputeHaVpnGateway().Schema)

// Set 'Required' schema elements
addRequiredFieldsToSchema(dsSchema, "name")

// Set 'Optional' schema elements
addOptionalFieldsToSchema(dsSchema, "project")
addOptionalFieldsToSchema(dsSchema, "region")

return &schema.Resource{
Read: dataSourceGoogleComputeHaVpnGatewayRead,
Schema: dsSchema,
}
}

func dataSourceGoogleComputeHaVpnGatewayRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

name := d.Get("name").(string)

project, err := getProject(d, config)
if err != nil {
return err
}

region, err := getRegion(d, config)
if err != nil {
return err
}

d.SetId(fmt.Sprintf("projects/%s/regions/%s/vpnGateways/%s", project, region, name))

return resourceComputeHaVpnGatewayRead(d, meta)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package google

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataSourceComputeHaVpnGateway(t *testing.T) {
t.Parallel()

gwName := fmt.Sprintf("tf-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceComputeHaVpnGatewayConfig(gwName),
Check: checkDataSourceStateMatchesResourceState("data.google_compute_ha_vpn_gateway.ha_gateway", "google_compute_ha_vpn_gateway.ha_gateway"),
},
},
})
}

func testAccDataSourceComputeHaVpnGatewayConfig(gwName string) string {
return fmt.Sprintf(`
resource "google_compute_ha_vpn_gateway" "ha_gateway" {
name = "%s"
network = google_compute_network.network1.id
}

resource "google_compute_network" "network1" {
name = "%s"
auto_create_subnetworks = false
}

data "google_compute_ha_vpn_gateway" "ha_gateway" {
name = google_compute_ha_vpn_gateway.ha_gateway.name
}
`, gwName, gwName)
}
1 change: 1 addition & 0 deletions mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func Provider() *schema.Provider {
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
"google_compute_global_forwarding_rule": dataSourceGoogleComputeGlobalForwardingRule(),
"google_compute_ha_vpn_gateway": dataSourceGoogleComputeHaVpnGateway(),
"google_compute_health_check": dataSourceGoogleComputeHealthCheck(),
"google_compute_image": dataSourceGoogleComputeImage(),
"google_compute_instance": dataSourceGoogleComputeInstance(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
subcategory: "Compute Engine"
layout: "google"
page_title: "Google: google_compute_ha_vpn_gateway"
sidebar_current: "docs-google-datasource-compute-ha-vpn-gateway"
description: |-
Get a HA VPN Gateway within GCE.
---

# google\_compute\_forwarding\_rule

Get a HA VPN Gateway within GCE from its name.

## Example Usage

```tf
data "google_compute_ha_vpn_gateway" "gateway" {
name = "foobar"
}
```

## Argument Reference

The following arguments are supported:

* `name` - (Required) The name of the forwarding rule.


- - -

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

* `region` - (Optional) The region in which the resource belongs. If it
is not provided, the project region is used.

## Attributes Reference
See [google_compute_ha_vpn_gateway](https://www.terraform.io/docs/providers/google/r/compute_ha_vpn_gateway.html) resource for details of the available attributes.