Skip to content

Adding IP Collection To Forwarding Rule #12914

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions mmv1/products/compute/ForwardingRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ examples:
- 'port_range'
- name: 'forwarding_rule_externallb_byoipv6'
primary_resource_id: 'default'
min_version: 'beta'
vars:
forwarding_rule_name: 'test-byoipv6-forwarding-rule'
forwarding_rule_name: 'byoipv6-forwarding-rule'
backend_name: 'website-backend'
network_name: 'website-net'
ip_address: '2600:1901:4457:1::/96'
test_vars_overrides:
ip_address: 'fmt.Sprintf("2600:1901:4457:1:%d:%d::/96", rand.Intn(9999), rand.Intn(9999))'
ip_address: 'fmt.Sprintf("2600:1901:4457:1:%d:%d::/96", acctest.RandIntRange(t, 0, 9999), acctest.RandIntRange(t, 0, 9999))'
ignore_read_extra:
- 'port_range'
- name: 'forwarding_rule_global_internallb'
Expand Down Expand Up @@ -667,6 +666,7 @@ properties:
- 'IPV6'
- name: ipCollection
type: String
diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths'
description: |
Resource reference of a PublicDelegatedPrefix. The PDP must be a sub-PDP
in EXTERNAL_IPV6_FORWARDING_RULE_CREATION mode.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Forwarding rule for External Network Load Balancing using Backend Services with IP Collection

resource "google_compute_forwarding_rule" "{{$.PrimaryResourceId}}" {
provider = google-beta
name = "{{index $.Vars "forwarding_rule_name"}}"
region = "us-central1"
port_range = 80
Expand All @@ -11,19 +10,17 @@ resource "google_compute_forwarding_rule" "{{$.PrimaryResourceId}}" {
ip_address = "{{index $.Vars "ip_address"}}"
network_tier = "PREMIUM"
backend_service = google_compute_region_backend_service.backend.id
ip_collection = "https://www.googleapis.com/compute/beta/projects/tf-static-byoip/regions/us-central1/publicDelegatedPrefixes/tf-test-forwarding-rule-mode-pdp"
ip_collection = "/projects/tf-static-byoip/regions/us-central1/publicDelegatedPrefixes/tf-test-forwarding-rule-mode-pdp"
}

resource "google_compute_region_backend_service" "backend" {
provider = google-beta
name = "{{index $.Vars "backend_name"}}"
region = "us-central1"
load_balancing_scheme = "EXTERNAL"
health_checks = [google_compute_region_health_check.hc.id]
}

resource "google_compute_region_health_check" "hc" {
provider = google-beta
name = "{{index $.Vars "backend_name"}}"
check_interval_sec = 1
timeout_sec = 1
Expand Down
15 changes: 15 additions & 0 deletions mmv1/third_party/terraform/acctest/test_utils.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ func RandInt(t *testing.T) int {
return rand.New(s.source).Int()
}

func RandIntRange(t *testing.T, minInt int, maxInt int) int {
if !IsVcrEnabled() {
return acctest.RandIntRange(minInt, maxInt)
}
envPath := os.Getenv("VCR_PATH")
vcrMode := os.Getenv("VCR_MODE")
s, err := vcrSource(t, envPath, vcrMode)
if err != nil {
// At this point we haven't created any resources, so fail fast
t.Fatal(err)
}

return rand.New(s.source).Intn(maxInt-minInt) + minInt
}

// ProtoV5ProviderFactories returns a muxed ProviderServer that uses the provider code from this repo (SDK and plugin-framework).
// Used to set ProtoV5ProviderFactories in a resource.TestStep within an acceptance test.
func ProtoV5ProviderFactories(t *testing.T) map[string]func() (tfprotov5.ProviderServer, error) {
Expand Down
Loading