diff --git a/google-beta/config.go b/google-beta/config.go index 69ee2efff0..9ece2a4f50 100644 --- a/google-beta/config.go +++ b/google-beta/config.go @@ -94,6 +94,7 @@ type Config struct { SqlBasePath string StorageBasePath string TpuBasePath string + VpcAccessBasePath string CloudBillingBasePath string clientBilling *cloudbilling.APIService diff --git a/google-beta/provider.go b/google-beta/provider.go index 9f04e54693..f3e7955780 100644 --- a/google-beta/provider.go +++ b/google-beta/provider.go @@ -122,6 +122,7 @@ func Provider() terraform.ResourceProvider { SqlCustomEndpointEntryKey: SqlCustomEndpointEntry, StorageCustomEndpointEntryKey: StorageCustomEndpointEntry, TpuCustomEndpointEntryKey: TpuCustomEndpointEntry, + VpcAccessCustomEndpointEntryKey: VpcAccessCustomEndpointEntry, // Handwritten Products / Versioned / Atypical Entries // start beta-only products @@ -242,6 +243,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) { GeneratedSqlResourcesMap, GeneratedStorageResourcesMap, GeneratedTpuResourcesMap, + GeneratedVpcAccessResourcesMap, map[string]*schema.Resource{ "google_app_engine_application": resourceAppEngineApplication(), "google_bigquery_dataset": resourceBigQueryDataset(), @@ -432,6 +434,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { config.SqlBasePath = d.Get(SqlCustomEndpointEntryKey).(string) config.StorageBasePath = d.Get(StorageCustomEndpointEntryKey).(string) config.TpuBasePath = d.Get(TpuCustomEndpointEntryKey).(string) + config.VpcAccessBasePath = d.Get(VpcAccessCustomEndpointEntryKey).(string) // Handwritten Products / Versioned / Atypical Entries config.IAPBasePath = d.Get(IAPCustomEndpointEntryKey).(string) @@ -494,6 +497,7 @@ func ConfigureBasePaths(c *Config) { c.SqlBasePath = SqlDefaultBasePath c.StorageBasePath = StorageDefaultBasePath c.TpuBasePath = TpuDefaultBasePath + c.VpcAccessBasePath = VpcAccessDefaultBasePath // Handwritten Products / Versioned / Atypical Entries // start beta-only products diff --git a/google-beta/provider_vpc_access_gen.go b/google-beta/provider_vpc_access_gen.go new file mode 100644 index 0000000000..bee11f4b38 --- /dev/null +++ b/google-beta/provider_vpc_access_gen.go @@ -0,0 +1,34 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import "github.com/hashicorp/terraform/helper/schema" + +// If the base path has changed as a result of your PR, make sure to update +// the provider_reference page! +var VpcAccessDefaultBasePath = "https://vpcaccess.googleapis.com/v1beta1/" +var VpcAccessCustomEndpointEntryKey = "vpc_access_custom_endpoint" +var VpcAccessCustomEndpointEntry = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateCustomEndpoint, + DefaultFunc: schema.MultiEnvDefaultFunc([]string{ + "GOOGLE_VPC_ACCESS_CUSTOM_ENDPOINT", + }, VpcAccessDefaultBasePath), +} + +var GeneratedVpcAccessResourcesMap = map[string]*schema.Resource{ + "google_vpc_access_connector": resourceVpcAccessConnector(), +} diff --git a/google-beta/resource_cloudfunctions_function.go b/google-beta/resource_cloudfunctions_function.go index b854e4f495..4e6cd0b831 100644 --- a/google-beta/resource_cloudfunctions_function.go +++ b/google-beta/resource_cloudfunctions_function.go @@ -201,6 +201,12 @@ func resourceCloudFunctionsFunction() *schema.Resource { ForceNew: true, }, + "vpc_connector": { + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: compareSelfLinkOrResourceName, + }, + "environment_variables": { Type: schema.TypeMap, Optional: true, @@ -367,6 +373,10 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro function.EnvironmentVariables = expandEnvironmentVariables(d) } + if v, ok := d.GetOk("vpc_connector"); ok { + function.VpcConnector = v.(string) + } + if v, ok := d.GetOk("max_instances"); ok { function.MaxInstances = int64(v.(int)) } @@ -417,6 +427,7 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error d.Set("runtime", function.Runtime) d.Set("service_account_email", function.ServiceAccountEmail) d.Set("environment_variables", function.EnvironmentVariables) + d.Set("vpc_connector", function.VpcConnector) if function.SourceArchiveUrl != "" { // sourceArchiveUrl should always be a Google Cloud Storage URL (e.g. gs://bucket/object) // https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions diff --git a/google-beta/resource_cloudfunctions_function_test.go b/google-beta/resource_cloudfunctions_function_test.go index e8b2ba3c73..68613a6dc1 100644 --- a/google-beta/resource_cloudfunctions_function_test.go +++ b/google-beta/resource_cloudfunctions_function_test.go @@ -326,6 +326,32 @@ func TestAccCloudFunctionsFunction_serviceAccountEmail(t *testing.T) { }) } +func TestAccCloudFunctionsFunction_vpcConnector(t *testing.T) { + t.Parallel() + + functionName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) + bucketName := fmt.Sprintf("tf-test-bucket-%d", acctest.RandInt()) + vpcConnectorName := fmt.Sprintf("tf-test-connector-%s", acctest.RandString(5)) + zipFilePath, err := createZIPArchiveForIndexJs(testHTTPTriggerPath) + projectNumber := os.Getenv("GOOGLE_PROJECT_NUMBER") + + if err != nil { + t.Fatal(err.Error()) + } + defer os.Remove(zipFilePath) // clean up + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProvidersOiCS, + CheckDestroy: testAccCheckCloudFunctionsFunctionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCloudFunctionsFunction_vpcConnector(projectNumber, functionName, bucketName, zipFilePath, vpcConnectorName), + }, + }, + }) +} + func testAccCheckCloudFunctionsFunctionDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) @@ -708,3 +734,56 @@ resource "google_cloudfunctions_function" "function" { entry_point = "helloGET" }`, bucketName, zipFilePath, functionName) } + +func testAccCloudFunctionsFunction_vpcConnector(projectNumber, functionName, bucketName, zipFilePath, vpcConnectorName string) string { + return fmt.Sprintf(` +provider "google-beta" { } + +resource "google_project_iam_member" "project" { + provider = "google-beta" + role = "roles/editor" + member = "serviceAccount:service-%s@gcf-admin-robot.iam.gserviceaccount.com" +} + +resource "google_vpc_access_connector" "connector" { + provider = "google-beta" + + name = "%s" + region = "us-central1" + ip_cidr_range = "10.10.0.0/28" + network = "default" +} + +resource "google_storage_bucket" "bucket" { + provider = "google-beta" + name = "%s" +} + +resource "google_storage_bucket_object" "archive" { + provider = "google-beta" + name = "index.zip" + bucket = google_storage_bucket.bucket.name + source = "%s" +} + +resource "google_cloudfunctions_function" "function" { + name = "%s" + provider = "google-beta" + + description = "test function" + available_memory_mb = 128 + source_archive_bucket = google_storage_bucket.bucket.name + source_archive_object = google_storage_bucket_object.archive.name + trigger_http = true + timeout = 61 + entry_point = "helloGET" + labels = { + my-label = "my-label-value" + } + environment_variables = { + TEST_ENV_VARIABLE = "test-env-variable-value" + } + max_instances = 10 + vpc_connector = google_vpc_access_connector.connector.self_link +}`, projectNumber, vpcConnectorName, bucketName, zipFilePath, functionName) +} diff --git a/google-beta/resource_vpc_access_connector.go b/google-beta/resource_vpc_access_connector.go new file mode 100644 index 0000000000..d6c90a519d --- /dev/null +++ b/google-beta/resource_vpc_access_connector.go @@ -0,0 +1,359 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "log" + "reflect" + "strconv" + "time" + + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" +) + +func resourceVpcAccessConnector() *schema.Resource { + return &schema.Resource{ + Create: resourceVpcAccessConnectorCreate, + Read: resourceVpcAccessConnectorRead, + Delete: resourceVpcAccessConnectorDelete, + + Importer: &schema.ResourceImporter{ + State: resourceVpcAccessConnectorImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(6 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "ip_cidr_range": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "region": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "max_throughput": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + ValidateFunc: validation.IntBetween(200, 1000), + Default: 1000, + }, + "min_throughput": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + ValidateFunc: validation.IntBetween(200, 1000), + Default: 200, + }, + "network": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "self_link": { + Type: schema.TypeString, + Computed: true, + }, + "state": { + Type: schema.TypeString, + Computed: true, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + } +} + +func resourceVpcAccessConnectorCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + obj := make(map[string]interface{}) + nameProp, err := expandVpcAccessConnectorName(d.Get("name"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { + obj["name"] = nameProp + } + networkProp, err := expandVpcAccessConnectorNetwork(d.Get("network"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("network"); !isEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { + obj["network"] = networkProp + } + ipCidrRangeProp, err := expandVpcAccessConnectorIpCidrRange(d.Get("ip_cidr_range"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ip_cidr_range"); !isEmptyValue(reflect.ValueOf(ipCidrRangeProp)) && (ok || !reflect.DeepEqual(v, ipCidrRangeProp)) { + obj["ipCidrRange"] = ipCidrRangeProp + } + minThroughputProp, err := expandVpcAccessConnectorMinThroughput(d.Get("min_throughput"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("min_throughput"); !isEmptyValue(reflect.ValueOf(minThroughputProp)) && (ok || !reflect.DeepEqual(v, minThroughputProp)) { + obj["minThroughput"] = minThroughputProp + } + maxThroughputProp, err := expandVpcAccessConnectorMaxThroughput(d.Get("max_throughput"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("max_throughput"); !isEmptyValue(reflect.ValueOf(maxThroughputProp)) && (ok || !reflect.DeepEqual(v, maxThroughputProp)) { + obj["maxThroughput"] = maxThroughputProp + } + + obj, err = resourceVpcAccessConnectorEncoder(d, meta, obj) + if err != nil { + return err + } + + url, err := replaceVars(d, config, "{{VpcAccessBasePath}}projects/{{project}}/locations/{{region}}/connectors?connectorId={{name}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new Connector: %#v", obj) + res, err := sendRequestWithTimeout(config, "POST", url, obj, d.Timeout(schema.TimeoutCreate)) + if err != nil { + return fmt.Errorf("Error creating Connector: %s", err) + } + + // Store the ID now + id, err := replaceVars(d, config, "{{name}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + project, err := getProject(d, config) + if err != nil { + return err + } + waitErr := vpcAccessOperationWaitTime( + config, res, project, "Creating Connector", + int(d.Timeout(schema.TimeoutCreate).Minutes())) + + if waitErr != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create Connector: %s", waitErr) + } + + log.Printf("[DEBUG] Finished creating Connector %q: %#v", d.Id(), res) + + // This is useful if the resource in question doesn't have a perfectly consistent API + // That is, the Operation for Create might return before the Get operation shows the + // completed state of the resource. + time.Sleep(5 * time.Second) + + return resourceVpcAccessConnectorRead(d, meta) +} + +func resourceVpcAccessConnectorRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{VpcAccessBasePath}}projects/{{project}}/locations/{{region}}/connectors/{{name}}") + if err != nil { + return err + } + + res, err := sendRequest(config, "GET", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("VpcAccessConnector %q", d.Id())) + } + + res, err = resourceVpcAccessConnectorDecoder(d, meta, res) + if err != nil { + return err + } + + if res == nil { + // Decoding the object has resulted in it being gone. It may be marked deleted + log.Printf("[DEBUG] Removing VpcAccessConnector because it no longer exists.") + d.SetId("") + return nil + } + + project, err := getProject(d, config) + if err != nil { + return err + } + if err := d.Set("project", project); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + + if err := d.Set("name", flattenVpcAccessConnectorName(res["name"], d)); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + if err := d.Set("network", flattenVpcAccessConnectorNetwork(res["network"], d)); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + if err := d.Set("ip_cidr_range", flattenVpcAccessConnectorIpCidrRange(res["ipCidrRange"], d)); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + if err := d.Set("state", flattenVpcAccessConnectorState(res["state"], d)); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + if err := d.Set("min_throughput", flattenVpcAccessConnectorMinThroughput(res["minThroughput"], d)); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + if err := d.Set("max_throughput", flattenVpcAccessConnectorMaxThroughput(res["maxThroughput"], d)); err != nil { + return fmt.Errorf("Error reading Connector: %s", err) + } + + return nil +} + +func resourceVpcAccessConnectorDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{VpcAccessBasePath}}projects/{{project}}/locations/{{region}}/connectors/{{name}}") + if err != nil { + return err + } + + var obj map[string]interface{} + log.Printf("[DEBUG] Deleting Connector %q", d.Id()) + res, err := sendRequestWithTimeout(config, "DELETE", url, obj, d.Timeout(schema.TimeoutDelete)) + if err != nil { + return handleNotFoundError(err, d, "Connector") + } + + project, err := getProject(d, config) + if err != nil { + return err + } + + err = vpcAccessOperationWaitTime( + config, res, project, "Deleting Connector", + int(d.Timeout(schema.TimeoutDelete).Minutes())) + + if err != nil { + return err + } + + log.Printf("[DEBUG] Finished deleting Connector %q: %#v", d.Id(), res) + return nil +} + +func resourceVpcAccessConnectorImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*Config) + if err := parseImportId([]string{ + "projects/(?P[^/]+)/locations/(?P[^/]+)/connectors/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := replaceVars(d, config, "{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil +} + +func flattenVpcAccessConnectorName(v interface{}, d *schema.ResourceData) interface{} { + if v == nil { + return v + } + return NameFromSelfLinkStateFunc(v) +} + +func flattenVpcAccessConnectorNetwork(v interface{}, d *schema.ResourceData) interface{} { + return v +} + +func flattenVpcAccessConnectorIpCidrRange(v interface{}, d *schema.ResourceData) interface{} { + return v +} + +func flattenVpcAccessConnectorState(v interface{}, d *schema.ResourceData) interface{} { + return v +} + +func flattenVpcAccessConnectorMinThroughput(v interface{}, d *schema.ResourceData) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { + return intVal + } // let terraform core handle it if we can't convert the string to an int. + } + return v +} + +func flattenVpcAccessConnectorMaxThroughput(v interface{}, d *schema.ResourceData) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { + return intVal + } // let terraform core handle it if we can't convert the string to an int. + } + return v +} + +func expandVpcAccessConnectorName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandVpcAccessConnectorNetwork(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandVpcAccessConnectorIpCidrRange(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandVpcAccessConnectorMinThroughput(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandVpcAccessConnectorMaxThroughput(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func resourceVpcAccessConnectorEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + delete(obj, "name") + return obj, nil +} + +func resourceVpcAccessConnectorDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { + // Take the returned long form of the name and use it as `self_link`. + // Then modify the name to be the user specified form. + // We can't just ignore_read on `name` as the linter will + // complain that the returned `res` is never used afterwards. + // Some field needs to be actually set, and we chose `name`. + d.Set("self_link", res["name"].(string)) + res["name"] = d.Get("name").(string) + return res, nil +} diff --git a/google-beta/resource_vpc_access_connector_generated_test.go b/google-beta/resource_vpc_access_connector_generated_test.go new file mode 100644 index 0000000000..8837ddbcfa --- /dev/null +++ b/google-beta/resource_vpc_access_connector_generated_test.go @@ -0,0 +1,83 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccVpcAccessConnector_vpcAccessConnectorExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(10), + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProvidersOiCS, + CheckDestroy: testAccCheckVpcAccessConnectorDestroy, + Steps: []resource.TestStep{ + { + Config: testAccVpcAccessConnector_vpcAccessConnectorExample(context), + }, + }, + }) +} + +func testAccVpcAccessConnector_vpcAccessConnectorExample(context map[string]interface{}) string { + return Nprintf(` +provider "google-beta" {} + +resource "google_vpc_access_connector" "connector" { + name = "my-connector%{random_suffix}" + provider = "google-beta" + region = "us-central1" + ip_cidr_range = "10.8.0.0/28" + network = "default" +} +`, context) +} + +func testAccCheckVpcAccessConnectorDestroy(s *terraform.State) error { + for name, rs := range s.RootModule().Resources { + if rs.Type != "google_vpc_access_connector" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := testAccProvider.Meta().(*Config) + + url, err := replaceVarsForTest(config, rs, "{{VpcAccessBasePath}}projects/{{project}}/locations/{{region}}/connectors/{{name}}") + if err != nil { + return err + } + + _, err = sendRequest(config, "GET", url, nil) + if err == nil { + return fmt.Errorf("VpcAccessConnector still exists at %s", url) + } + } + + return nil +} diff --git a/google-beta/vpc_access_operation.go b/google-beta/vpc_access_operation.go new file mode 100644 index 0000000000..e8a271c8b2 --- /dev/null +++ b/google-beta/vpc_access_operation.go @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- +package google + +import ( + "fmt" +) + +type VpcAccessOperationWaiter struct { + Config *Config + CommonOperationWaiter +} + +func (w *VpcAccessOperationWaiter) QueryOp() (interface{}, error) { + if w == nil { + return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") + } + // Returns the proper get. + url := fmt.Sprintf("https://vpcaccess.googleapis.com/v1beta1/%s", w.CommonOperationWaiter.Op.Name) + return sendRequest(w.Config, "GET", url, nil) +} + +func vpcAccessOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error { + if val, ok := op["name"]; !ok || val == "" { + // This was a synchronous call - there is no operation to wait for. + return nil + } + w := &VpcAccessOperationWaiter{ + Config: config, + } + if err := w.CommonOperationWaiter.SetOp(op); err != nil { + return err + } + return OperationWait(w, activity, timeoutMinutes) +} diff --git a/website/docs/r/cloudfunctions_function.html.markdown b/website/docs/r/cloudfunctions_function.html.markdown index 96d25b75f3..c617391381 100644 --- a/website/docs/r/cloudfunctions_function.html.markdown +++ b/website/docs/r/cloudfunctions_function.html.markdown @@ -78,6 +78,8 @@ defaults to `"nodejs6"`. It's recommended that you override the default, as * `environment_variables` - (Optional) A set of key/value environment variable pairs to assign to the function. +* `vpc_connector` - (Optional) The VPC Network Connector that this cloud function can connect to. It can be either the fully-qualified URI, or the short name of the network connector resource. The format of this field is `projects/*/locations/*/connectors/*`. + * `source_archive_bucket` - (Optional) The GCS bucket containing the zip archive which contains the function. * `source_archive_object` - (Optional) The source archive object (file) in archive bucket. diff --git a/website/docs/r/vpc_access_connector.html.markdown b/website/docs/r/vpc_access_connector.html.markdown new file mode 100644 index 0000000000..1923d21016 --- /dev/null +++ b/website/docs/r/vpc_access_connector.html.markdown @@ -0,0 +1,124 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in +# .github/CONTRIBUTING.md. +# +# ---------------------------------------------------------------------------- +layout: "google" +page_title: "Google: google_vpc_access_connector" +sidebar_current: "docs-google-vpc-access-connector" +description: |- + Serverless VPC Access connector resource. +--- + +# google\_vpc\_access\_connector + +Serverless VPC Access connector resource. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/provider_versions.html) for more details on beta resources. + +To get more information about Connector, see: + +* [API documentation](https://cloud.google.com/vpc/docs/reference/vpcaccess/rest/v1beta1/projects.locations.connectors) +* How-to Guides + * [Configuring Serverless VPC Access](https://cloud.google.com/vpc/docs/configure-serverless-vpc-access) + + +## Example Usage - Vpc Access Connector + + +```hcl +provider "google-beta" {} + +resource "google_vpc_access_connector" "connector" { + name = "my-connector" + provider = "google-beta" + region = "us-central1" + ip_cidr_range = "10.8.0.0/28" + network = "default" +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `name` - + (Required) + The name of the resource (Max 25 characters). + +* `ip_cidr_range` - + (Required) + The range of internal addresses that follows RFC 4632 notation. Example: `10.132.0.0/28`. + +* `region` - + (Required) + Region where the VPC Access connector resides + + +- - - + + +* `network` - + (Optional) + Name of a VPC network. + +* `min_throughput` - + (Optional) + Minimum throughput of the connector in Mbps. Default and min is 200. + +* `max_throughput` - + (Optional) + Maximum throughput of the connector in Mbps, must be greater than `min_throughput`. Default is 1000. + +* `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: + + +* `state` - + State of the VPC access connector. + +* `self_link` - + The fully qualifed name of this VPC connector + + +## Timeouts + +This resource provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - Default is 6 minutes. +- `delete` - Default is 10 minutes. + +## Import + +Connector can be imported using any of these accepted formats: + +``` +$ terraform import -provider=google-beta google_vpc_access_connector.default projects/{{project}}/locations/{{region}}/connectors/{{name}} +$ terraform import -provider=google-beta google_vpc_access_connector.default {{project}}/{{region}}/{{name}} +$ terraform import -provider=google-beta google_vpc_access_connector.default {{region}}/{{name}} +$ terraform import -provider=google-beta google_vpc_access_connector.default {{name}} +``` + +-> If you're importing a resource with beta features, make sure to include `-provider=google-beta` +as an argument so that Terraform uses the correct provider to import your resource.