Skip to content

Commit f852342

Browse files
add vpc_firewall_create sample (#5024) (#3538)
Signed-off-by: Modular Magician <[email protected]>
1 parent 2516b33 commit f852342

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

.changelog/5024.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/resource_compute_firewall_generated_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,49 @@ resource "google_compute_network" "default" {
7272
`, context)
7373
}
7474

75+
func TestAccComputeFirewall_firewallWithTargetTagsExample(t *testing.T) {
76+
t.Parallel()
77+
78+
context := map[string]interface{}{
79+
"project": getTestProjectFromEnv(),
80+
"random_suffix": randString(t, 10),
81+
}
82+
83+
vcrTest(t, resource.TestCase{
84+
PreCheck: func() { testAccPreCheck(t) },
85+
Providers: testAccProviders,
86+
CheckDestroy: testAccCheckComputeFirewallDestroyProducer(t),
87+
Steps: []resource.TestStep{
88+
{
89+
Config: testAccComputeFirewall_firewallWithTargetTagsExample(context),
90+
},
91+
{
92+
ResourceName: "google_compute_firewall.rules",
93+
ImportState: true,
94+
ImportStateVerify: true,
95+
ImportStateVerifyIgnore: []string{"network"},
96+
},
97+
},
98+
})
99+
}
100+
101+
func testAccComputeFirewall_firewallWithTargetTagsExample(context map[string]interface{}) string {
102+
return Nprintf(`
103+
resource "google_compute_firewall" "rules" {
104+
project = "%{project}"
105+
name = "tf-test-my-firewall-rule%{random_suffix}"
106+
network = "default"
107+
description = "Creates firewall rule targeting tagged instances"
108+
109+
allow {
110+
protocol = "tcp"
111+
ports = ["80", "8080", "1000-2000"]
112+
}
113+
target_tags = ["web"]
114+
}
115+
`, context)
116+
}
117+
75118
func testAccCheckComputeFirewallDestroyProducer(t *testing.T) func(s *terraform.State) error {
76119
return func(s *terraform.State) error {
77120
for name, rs := range s.RootModule().Resources {

google-beta/resource_gke_hub_feature_membership_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"testing"
77

8-
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
8+
dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
99
gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

website/docs/r/compute_firewall.html.markdown

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ resource "google_compute_network" "default" {
7272
name = "test-network"
7373
}
7474
```
75+
## Example Usage - Firewall With Target Tags
76+
77+
78+
```hcl
79+
resource "google_compute_firewall" "rules" {
80+
project = "my-project-name"
81+
name = "my-firewall-rule"
82+
network = "default"
83+
description = "Creates firewall rule targeting tagged instances"
84+
85+
allow {
86+
protocol = "tcp"
87+
ports = ["80", "8080", "1000-2000"]
88+
}
89+
target_tags = ["web"]
90+
}
91+
```
7592

7693
## Argument Reference
7794

0 commit comments

Comments
 (0)