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

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
megan07 authored and modular-magician committed Aug 12, 2019
1 parent 20e2ac6 commit bb79586
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 1 addition & 4 deletions google/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,7 @@ func mergeAuditConfigs(auditConfigs []*cloudresourcemanager.AuditConfig) []*clou
// Flattens AuditConfigs so each role has a single Binding with combined members\
func removeAllAuditConfigsWithService(ac []*cloudresourcemanager.AuditConfig, service string) []*cloudresourcemanager.AuditConfig {
acMap := createIamAuditConfigsMap(ac)
if _, ok := acMap[service]; ok {
delete(acMap, service)
}

delete(acMap, service)
return listFromIamAuditConfigMap(acMap)
}

Expand Down
11 changes: 11 additions & 0 deletions google/resource_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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 @@ -360,6 +366,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 @@ -410,6 +420,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 bb79586

Please sign in to comment.