-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com> Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
6868751
commit 68ec524
Showing
5 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-datasource | ||
`google_vpc_access_connector` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceVPCAccessConnector() *schema.Resource { | ||
|
||
dsSchema := datasourceSchemaFromResourceSchema(resourceVPCAccessConnector().Schema) | ||
addRequiredFieldsToSchema(dsSchema, "name") | ||
addOptionalFieldsToSchema(dsSchema, "project", "region") | ||
|
||
return &schema.Resource{ | ||
Read: dataSourceVPCAccessConnectorRead, | ||
Schema: dsSchema, | ||
} | ||
} | ||
|
||
func dataSourceVPCAccessConnectorRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
id, err := replaceVars(d, config, "projects/{{project}}/locations/{{region}}/connectors/{{name}}") | ||
if err != nil { | ||
return fmt.Errorf("Error constructing id: %s", err) | ||
} | ||
|
||
d.SetId(id) | ||
|
||
return resourceVPCAccessConnectorRead(d, meta) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccVPCAccessConnectorDatasource_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccVPCAccessConnectorDatasourceConfig(randString(t, 10)), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkDataSourceStateMatchesResourceStateWithIgnores( | ||
"data.google_vpc_access_connector.connector", | ||
"google_vpc_access_connector.connector", | ||
map[string]struct{}{ | ||
// Ignore fields not returned in response | ||
"self_link": {}, | ||
"region": {}, | ||
}, | ||
), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccVPCAccessConnectorDatasourceConfig(suffix string) string { | ||
return fmt.Sprintf(` | ||
resource "google_vpc_access_connector" "connector" { | ||
name = "vpc-con-test-%s" | ||
ip_cidr_range = "10.8.0.0/28" | ||
network = "default" | ||
region = "us-central1" | ||
} | ||
data "google_vpc_access_connector" "connector" { | ||
name = google_vpc_access_connector.connector.name | ||
} | ||
`, suffix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
subcategory: "Serverless VPC Access" | ||
page_title: "Google: google_vpc_access_connector" | ||
description: |- | ||
Get a Serverless VPC Access connector. | ||
--- | ||
|
||
# google\_vpc\_access\_connector | ||
|
||
Get a Serverless VPC Access connector. | ||
|
||
To get more information about Connector, see: | ||
|
||
* [API documentation](https://cloud.google.com/vpc/docs/reference/vpcaccess/rest/v1/projects.locations.connectors) | ||
* How-to Guides | ||
* [Configuring Serverless VPC Access](https://cloud.google.com/vpc/docs/configure-serverless-vpc-access) | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "google_vpc_access_connector" "sample" { | ||
name = "vpc-con" | ||
} | ||
resource "google_vpc_access_connector" "connector" { | ||
name = "vpc-con" | ||
ip_cidr_range = "10.8.0.0/28" | ||
network = "default" | ||
region = "us-central1" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) Name of the resource. | ||
|
||
- - - | ||
|
||
* `project` - (Optional) The ID of 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 provider region is used. | ||
|
||
## Attributes Reference | ||
|
||
See [google_vpc_access_connector](https://www.terraform.io/docs/providers/google/r/vpc_access_connector.html) resource for details of the available attributes. |