Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for egress_settings on google_app_engine_standard_app_version… #12606

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .changelog/6535.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
appengine: Added `egress_setting` for field `vpc_access_connector` to `google_app_engine_standard_app_version`
```
22 changes: 22 additions & 0 deletions google/resource_app_engine_standard_app_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ Substitute '<language>' with 'python', 'java', 'php', 'ruby', 'go' or 'nodejs'.`
Required: true,
Description: `Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1.`,
},
"egress_setting": {
Type: schema.TypeString,
Optional: true,
Description: `The egress setting for the connector, controlling what traffic is diverted through it.`,
},
},
},
},
Expand Down Expand Up @@ -1116,12 +1121,18 @@ func flattenAppEngineStandardAppVersionVPCAccessConnector(v interface{}, d *sche
transformed := make(map[string]interface{})
transformed["name"] =
flattenAppEngineStandardAppVersionVPCAccessConnectorName(original["name"], d, config)
transformed["egress_setting"] =
flattenAppEngineStandardAppVersionVPCAccessConnectorEgressSetting(original["egressSetting"], d, config)
return []interface{}{transformed}
}
func flattenAppEngineStandardAppVersionVPCAccessConnectorName(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAppEngineStandardAppVersionVPCAccessConnectorEgressSetting(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAppEngineStandardAppVersionInboundServices(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -1752,13 +1763,24 @@ func expandAppEngineStandardAppVersionVPCAccessConnector(v interface{}, d Terraf
transformed["name"] = transformedName
}

transformedEgressSetting, err := expandAppEngineStandardAppVersionVPCAccessConnectorEgressSetting(original["egress_setting"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEgressSetting); val.IsValid() && !isEmptyValue(val) {
transformed["egressSetting"] = transformedEgressSetting
}

return transformed, nil
}

func expandAppEngineStandardAppVersionVPCAccessConnectorName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandAppEngineStandardAppVersionVPCAccessConnectorEgressSetting(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandAppEngineStandardAppVersionInboundServices(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
v = v.(*schema.Set).List()
return v, nil
Expand Down
20 changes: 11 additions & 9 deletions google/resource_app_engine_standard_app_version_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package google

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"testing"

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

func TestAccAppEngineStandardAppVersion_update(t *testing.T) {
Expand Down Expand Up @@ -166,14 +167,14 @@ resource "google_project_service" "vpcaccess_api" {
}

resource "google_vpc_access_connector" "bar" {
depends_on = [
depends_on = [
google_project_service.vpcaccess_api
]
project = google_project.my_project.project_id
name = "bar"
region = "us-central1"
ip_cidr_range = "10.8.0.0/28"
network = "default"
project = google_project.my_project.project_id
name = "bar"
region = "us-central1"
ip_cidr_range = "10.8.0.0/28"
network = "default"
}

resource "google_app_engine_standard_app_version" "foo" {
Expand All @@ -182,8 +183,9 @@ resource "google_app_engine_standard_app_version" "foo" {
service = "default"
runtime = "python38"

vpc_access_connector {
name = "${google_vpc_access_connector.bar.id}"
vpc_access_connector {
name = "${google_vpc_access_connector.bar.id}"
egress_setting = "ALL_TRAFFIC"
}

entrypoint {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/app_engine_standard_app_version.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ The following arguments are supported:
(Required)
Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1.

* `egress_setting` -
(Optional)
The egress setting for the connector, controlling what traffic is diverted through it.

<a name="nested_automatic_scaling"></a>The `automatic_scaling` block supports:

* `max_concurrent_requests` -
Expand Down