mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
compute_firewall: set source_ranges to Computed to avoid perpetual diff
If this is not set in Terraform, then the API defaults to 0.0.0.0/0, Terraform would then attempt to remove that value and so on.
This commit is contained in:
parent
09c422a094
commit
763f67c22c
|
@ -76,6 +76,7 @@ func resourceComputeFirewall() *schema.Resource {
|
|||
"source_ranges": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
|
|
@ -61,6 +61,27 @@ func TestAccComputeFirewall_update(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccComputeFirewall_noSource(t *testing.T) {
|
||||
var firewall compute.Firewall
|
||||
networkName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
|
||||
firewallName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeFirewallDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeFirewall_noSource(networkName, firewallName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeFirewallExists(
|
||||
"google_compute_firewall.foobar", &firewall),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckComputeFirewallDestroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
|
@ -161,3 +182,22 @@ func testAccComputeFirewall_update(network, firewall string) string {
|
|||
}
|
||||
}`, network, firewall)
|
||||
}
|
||||
|
||||
func testAccComputeFirewall_noSource(network, firewall string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "foobar" {
|
||||
name = "%s"
|
||||
ipv4_range = "10.0.0.0/16"
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
network = "${google_compute_network.foobar.name}"
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = [22]
|
||||
}
|
||||
}`, network, firewall)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user