Skip to content
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
23 changes: 23 additions & 0 deletions mmv1/products/compute/ForwardingRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ examples:
ip_name: 'website-ip'
backend_name: 'service-backend'
external_forwarding_rule_name: 'external-forwarding-rule'
- !ruby/object:Provider::Terraform::Examples
name: "forwarding_rule_internallb_ipv6"
primary_resource_id: "default"
vars:
forwarding_rule_name: "ilb-ipv6-forwarding-rule"
backend_name: "ilb-ipv6-backend"
network_name: "net-ipv6"
subnet_name: "subnet-internal-ipv6"
ignore_read_extra:
- "port_range"
- "target"
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/labels.erb
parameters:
Expand Down Expand Up @@ -617,3 +628,15 @@ properties:
send_empty_value: true
immutable: true
ignore_read: true
- !ruby/object:Api::Type::Enum
name: 'ipVersion'
description: |
The IP address version that will be used by this forwarding rule.
Valid options are IPV4 and IPV6.

If not set, the IPv4 address will be used by default.
values:
- :IPV4
- :IPV6
immutable: true
default_from_api: true
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "google_compute_forwarding_rule" "<%= ctx[:primary_resource_id] %>" {
all_ports = true
network = google_compute_network.default.name
subnetwork = google_compute_subnetwork.default.name
ip_version = "IPV4"
}

resource "google_compute_region_backend_service" "backend" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Forwarding rule for Internal Load Balancing
resource "google_compute_forwarding_rule" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['forwarding_rule_name'] %>"
region = "us-central1"

load_balancing_scheme = "INTERNAL"
backend_service = google_compute_region_backend_service.backend.id
all_ports = true
network = google_compute_network.default.name
subnetwork = google_compute_subnetwork.default.name
ip_version = "IPV6"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agh, I just thought of a possible failure case. Some APIs, GCE in particular, will sometimes return a null when the default value is returned from the API. Could you amend an existing test to explicitly send IPV4? That'll confirm whether we need to mitigate that behaviour here or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it, I'll try modify one basic test case. Bth, should we do default_value = IPV4, instead of default_from_api=true?

@rileykarson rileykarson Aug 1, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Either is fine. Since the field is immutable, default_from_api is a little safer. Explicit default values create a slightly cleaner plan, though, since the default value is known when planning.

}

resource "google_compute_region_backend_service" "backend" {
name = "<%= ctx[:vars]['backend_name'] %>"
region = "us-central1"
health_checks = [google_compute_health_check.hc.id]
}

resource "google_compute_health_check" "hc" {
name = "check-<%= ctx[:vars]['backend_name'] %>"
check_interval_sec = 1
timeout_sec = 1

tcp_health_check {
port = "80"
}
}

resource "google_compute_network" "default" {
name = "<%= ctx[:vars]['network_name'] %>"
auto_create_subnetworks = false
enable_ula_internal_ipv6 = true
}

resource "google_compute_subnetwork" "default" {
name = "<%= ctx[:vars]['subnet_name'] %>"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
stack_type = "IPV4_IPV6"
ipv6_access_type = "INTERNAL"
network = google_compute_network.default.id
}