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

Compute serviceattachment dcl #5444

Closed
Closed
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
1 change: 1 addition & 0 deletions mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
SecurityPolicy: !ruby/object:Overrides::Terraform::ResourceOverride
exclude: true
ServiceAttachment: !ruby/object:Overrides::Terraform::ResourceOverride
exclude: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "service_attachment_basic"
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ end # products.each do
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
"google_compute_service_attachment": resourceComputeServiceAttachment(),
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
"google_eventarc_trigger": resourceEventarcTrigger(),
<% unless version == 'ga' -%>
Expand Down
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/utils/provider_test.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ func initializeReleaseDiffTest(c resource.TestCase) resource.TestCase {
replacementSteps = append(replacementSteps, newStep)
}
replacementSteps = append(replacementSteps, testStep)
} else {
} else if !testStep.ImportStateVerify {
replacementSteps = append(replacementSteps, testStep)
}
}
Expand Down
4 changes: 0 additions & 4 deletions tpgtools/overrides/compute/beta/firewall_policy_rule.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
- type: DIFF_SUPPRESS_FUNC
field: target_resources
details:
diffsuppressfunc: compareSelfLinkOrResourceName
12 changes: 12 additions & 0 deletions tpgtools/overrides/compute/beta/service_attachment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- type: EXCLUDE
field: region
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, weird- the base DCL resource includes a (presumably output-only) region field but also a location field which maps to the region field in the API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the way KCC requested we name the fields. location corresponds to the URL parameter.

- type: EXCLUDE
field: service_attachment_id
- type: CUSTOM_NAME
details:
name: region
field: location
- type: DIFF_SUPPRESS_FUNC
field: location
details:
diffsuppressfunc: compareSelfLinkOrResourceName
4 changes: 0 additions & 4 deletions tpgtools/overrides/compute/firewall_policy_rule.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
- type: DIFF_SUPPRESS_FUNC
field: target_resources
details:
diffsuppressfunc: compareSelfLinkOrResourceName
78 changes: 78 additions & 0 deletions tpgtools/overrides/compute/samples/serviceattachment/basic.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
resource "google_compute_service_attachment" "primary" {
name = "{{my-psc-ilb}}"
region = "{{region}}"
description = "A service attachment configured with Terraform"

enable_proxy_protocol = true
connection_preference = "ACCEPT_AUTOMATIC"
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
target_service = google_compute_forwarding_rule.psc_ilb_target_service.id
}

resource "google_compute_address" "psc_ilb_consumer_address" {
name = "{{psc-ilb-consumer-address}}"
region = "{{region}}"

subnetwork = "default"
address_type = "INTERNAL"
}

resource "google_compute_forwarding_rule" "psc_ilb_consumer" {
name = "{{psc-ilb-consumer-forwarding-rule}}"
region = "{{region}}"

target = google_compute_service_attachment.primary.id
load_balancing_scheme = "" # need to override EXTERNAL default when target is a service attachment
network = "default"
ip_address = google_compute_address.psc_ilb_consumer_address.id
}

resource "google_compute_forwarding_rule" "psc_ilb_target_service" {
name = "{{producer-forwarding-rule}}"
region = "{{region}}"

load_balancing_scheme = "INTERNAL"
backend_service = google_compute_region_backend_service.producer_service_backend.id
all_ports = true
network = google_compute_network.psc_ilb_network.name
subnetwork = google_compute_subnetwork.psc_ilb_producer_subnetwork.name
}

resource "google_compute_region_backend_service" "producer_service_backend" {
name = "{{producer-service}}"
region = "{{region}}"

health_checks = [google_compute_health_check.producer_service_health_check.id]
}

resource "google_compute_health_check" "producer_service_health_check" {
name = "{{producer-service-health-check}}"

check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
port = "80"
}
}

resource "google_compute_network" "psc_ilb_network" {
name = "{{psc-ilb-network}}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" {
name = "{{psc-ilb-producer-subnetwork}}"
region = "{{region}}"

network = google_compute_network.psc_ilb_network.id
ip_cidr_range = "10.0.0.0/16"
}

resource "google_compute_subnetwork" "psc_ilb_nat" {
name = "{{psc-ilb-nat}}"
region = "{{region}}"

network = google_compute_network.psc_ilb_network.id
purpose = "PRIVATE_SERVICE_CONNECT"
ip_cidr_range = "10.1.0.0/16"
}
24 changes: 24 additions & 0 deletions tpgtools/overrides/compute/samples/serviceattachment/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# optional test level config -- needed for updates consumer_lists.tf.tmpl def
updates:
- resource: ./basic_update.tf.tmpl
variables:
- name: "region"
type: "region"
- name: "my-psc-ilb"
type: "resource_name"
- name: "psc-ilb-consumer-address"
type: "resource_name"
- name: "psc-ilb-consumer-forwarding-rule"
type: "resource_name"
- name: "producer-forwarding-rule"
type: "resource_name"
- name: "producer-service"
type: "resource_name"
- name: "producer-service-health-check"
type: "resource_name"
- name: "psc-ilb-network"
type: "resource_name"
- name: "psc-ilb-producer-subnetwork"
type: "resource_name"
- name: "psc-ilb-nat"
type: "resource_name"
Loading