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

Fix service_attachment.target_service validation #12571

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions mmv1/products/compute/ServiceAttachment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ properties:
required: true
immutable: true
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
custom_expand: 'templates/terraform/custom_expand/service_attachment_target_service.go.tmpl'
- name: 'natSubnets'
type: Array
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
func expand{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
resource := strings.Split(v.(string), "/")
Samir-Cit marked this conversation as resolved.
Show resolved Hide resolved
resourceKind := resource[len(resource)-2]
resourceBound := resource[len(resource)-4]

_, err := tpgresource.ParseRegionalFieldValue(resourceKind, v.(string), "project", resourceBound, "zone", d, config, true)
if err != nil {
return nil, fmt.Errorf("Invalid value for target_service: %s", err)
Samir-Cit marked this conversation as resolved.
Show resolved Hide resolved
}

return v, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ resource "google_compute_service_attachment" "default" {
enable_proxy_protocol = false
connection_preference = "ACCEPT_AUTOMATIC"
nat_subnets = [google_compute_subnetwork.psc.id]
target_service = google_network_services_gateway.foobar.self_link
target_service = google_network_services_gateway.default.self_link
}

resource "google_certificate_manager_certificate" "default" {
Expand Down Expand Up @@ -473,14 +473,14 @@ resource "google_network_security_gateway_security_policy_rule" "default" {
basic_profile = "ALLOW"
}

resource "google_network_services_gateway" "foobar" {
resource "google_network_services_gateway" "default" {
name = "tf-test-sa-swp-%{random_suffix}"
location = "us-east1"
addresses = ["10.128.0.99"]
type = "SECURE_WEB_GATEWAY"
ports = [443]
description = "my description"
scope = "%s"
scope = "serviceAttachment"
certificate_urls = [google_certificate_manager_certificate.default.id]
gateway_security_policy = google_network_security_gateway_security_policy.default.id
network = google_compute_network.default.id
Expand Down
Loading