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_firewall: set source_ranges to Computed to avoid perpetual diff #147

Merged
merged 1 commit into from
Jun 22, 2017
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
1 change: 1 addition & 0 deletions google/resource_compute_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
40 changes: 40 additions & 0 deletions google/resource_compute_firewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}