Skip to content

Commit

Permalink
Add vpc access connector resource and vpc_connector attribute to clou…
Browse files Browse the repository at this point in the history
…d functions
  • Loading branch information
megan07 authored Aug 12, 2019
2 parents 60e848e + 266d83b commit 3022649
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions google/resource_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/cloudfunctions_function.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3022649

Please sign in to comment.