mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
Merge pull request #12662 from hashicorp/paddy_9051_forwarding_rule_cycle
provider/google: fix single port diff cycle
This commit is contained in:
commit
479e027d4c
@ -76,6 +76,12 @@ func resourceComputeForwardingRule() *schema.Resource {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
|
||||
if old == new+"-"+new {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
},
|
||||
|
||||
"ports": &schema.Schema{
|
||||
|
@ -29,6 +29,26 @@ func TestAccComputeForwardingRule_basic(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccComputeForwardingRule_singlePort(t *testing.T) {
|
||||
poolName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeForwardingRule_singlePort(poolName, ruleName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeForwardingRuleExists(
|
||||
"google_compute_forwarding_rule.foobar"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccComputeForwardingRule_ip(t *testing.T) {
|
||||
addrName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
poolName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
@ -133,6 +153,23 @@ resource "google_compute_forwarding_rule" "foobar" {
|
||||
`, poolName, ruleName)
|
||||
}
|
||||
|
||||
func testAccComputeForwardingRule_singlePort(poolName, ruleName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_pool" "foobar-tp" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
instances = ["us-central1-a/foo", "us-central1-b/bar"]
|
||||
name = "%s"
|
||||
}
|
||||
resource "google_compute_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "UDP"
|
||||
name = "%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_pool.foobar-tp.self_link}"
|
||||
}
|
||||
`, poolName, ruleName)
|
||||
}
|
||||
|
||||
func testAccComputeForwardingRule_ip(addrName, poolName, ruleName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_address" "foo" {
|
||||
|
Loading…
Reference in New Issue
Block a user