Skip to content

Commit 1515c1c

Browse files
authored
Bump Cloud Armor Hierchical Policies - Security Policies to GA (#15695)
1 parent 14361c1 commit 1515c1c

File tree

6 files changed

+41
-63
lines changed

6 files changed

+41
-63
lines changed

mmv1/products/compute/OrganizationSecurityPolicy.yaml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ name: 'OrganizationSecurityPolicy'
1616
api_resource_type_kind: SecurityPolicy
1717
description: |
1818
Organization security policies are used to control incoming/outgoing traffic.
19-
min_version: 'beta'
2019
references:
2120
guides:
2221
'Creating a firewall policy': 'https://cloud.google.com/vpc/docs/using-firewall-policies#create-policy'
23-
api: 'https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies'
22+
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/organizationSecurityPolicies'
2423
docs:
2524
id_format: 'locations/global/securityPolicies/{{policy_id}}'
2625
base_url: 'locations/global/securityPolicies?parentId={{parent}}'
@@ -37,12 +36,13 @@ custom_code:
3736
post_create: 'templates/terraform/post_create/org_security_policy.go.tmpl'
3837
post_delete: 'templates/terraform/post_delete/org_security_policy.go.tmpl'
3938
post_update: 'templates/terraform/post_update/org_security_policy.go.tmpl'
40-
# TODO: Remove once b/154369201 is closed.
39+
# TODO: Remove once b/154369201 is closed.
4140
test_check_destroy: 'templates/terraform/custom_check_destroy/skip_delete_during_test.go.tmpl'
4241
examples:
4342
- name: 'organization_security_policy_basic'
4443
primary_resource_id: 'policy'
45-
min_version: 'beta'
44+
vars:
45+
short_name: "my-short-name"
4646
test_env_vars:
4747
org_id: 'ORG_ID'
4848
parameters:
@@ -51,49 +51,44 @@ parameters:
5151
description: |
5252
The parent of this OrganizationSecurityPolicy in the Cloud Resource Hierarchy.
5353
Format: organizations/{organization_id} or folders/{folder_id}
54-
min_version: 'beta'
5554
required: true
5655
immutable: true
5756
properties:
5857
- name: 'displayName'
5958
type: String
6059
description: |
6160
User-provided name of the organization security policy. The name should be unique in the organization in which the security policy is created. This should only be used when SecurityPolicyType is FIREWALL.
62-
min_version: 'beta'
6361
immutable: true
6462
ignore_read: true
6563
- name: 'description'
6664
type: String
6765
description: |
6866
A textual description for the organization security policy.
69-
min_version: 'beta'
7067
- name: 'shortName'
7168
type: String
7269
description: |
7370
User-provided name of the organization security policy. The name should be unique in the organization in which the security policy is created. This should only be used when SecurityPolicyType is CLOUD_ARMOR.
74-
min_version: 'beta'
7571
immutable: true
7672
- name: 'fingerprint'
7773
type: Fingerprint
7874
description: |
7975
Fingerprint of this resource. This field is used internally during
8076
updates of this resource.
81-
min_version: 'beta'
8277
output: true
8378
- name: 'policy_id'
8479
type: String
8580
description: |
8681
The unique identifier for the resource. This identifier is defined by the server.
8782
api_name: id
88-
min_version: 'beta'
8983
output: true
9084
- name: 'type'
9185
type: Enum
9286
description: |
9387
The type indicates the intended use of the security policy. This field can be set only at resource creation time.
94-
min_version: 'beta'
88+
89+
**NOTE** : 'FIREWALL' type is deprecated and will be removed in a future major release. Please use 'google_compute_firewall_policy' instead."
9590
immutable: true
96-
default_value: "FIREWALL"
91+
default_from_api: true
9792
enum_values:
9893
- 'FIREWALL'
9994
- 'CLOUD_ARMOR'

mmv1/templates/terraform/examples/organization_security_policy_association_basic.tf.tmpl

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,10 @@ resource "google_folder" "security_policy_target" {
66
}
77

88
resource "google_compute_organization_security_policy" "policy" {
9-
provider = google-beta
9+
provider = google-beta
1010
display_name = "tf-test%{random_suffix}"
1111
parent = google_folder.security_policy_target.name
12-
}
13-
14-
resource "google_compute_organization_security_policy_rule" "{{$.PrimaryResourceId}}" {
15-
provider = google-beta
16-
policy_id = google_compute_organization_security_policy.{{$.PrimaryResourceId}}.id
17-
action = "allow"
18-
19-
direction = "INGRESS"
20-
enable_logging = true
21-
match {
22-
config {
23-
src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"]
24-
layer4_config {
25-
ip_protocol = "tcp"
26-
ports = ["22"]
27-
}
28-
layer4_config {
29-
ip_protocol = "icmp"
30-
}
31-
}
32-
}
33-
priority = 100
12+
type = "FIREWALL"
3413
}
3514

3615
resource "google_compute_organization_security_policy_association" "{{$.PrimaryResourceId}}" {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "google_compute_organization_security_policy" "{{$.PrimaryResourceId}}" {
2-
provider = google-beta
3-
display_name = "tf-test%{random_suffix}"
4-
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
2+
short_name = "{{index $.Vars "short_name"}}"
3+
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
4+
type = "CLOUD_ARMOR"
55
}

mmv1/templates/terraform/examples/organization_security_policy_rule_basic.tf.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
resource "google_compute_organization_security_policy" "{{$.PrimaryResourceId}}" {
2-
provider = google-beta
2+
provider = google-beta
33
display_name = "tf-test%{random_suffix}"
44
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
5+
type = "FIREWALL"
56
}
67

78
resource "google_compute_organization_security_policy_rule" "{{$.PrimaryResourceId}}" {

mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_rule_test.go.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ resource "google_folder" "security_policy_target" {
5353
resource "google_compute_organization_security_policy" "policy" {
5454
display_name = "tf-test%{random_suffix}"
5555
parent = google_folder.security_policy_target.name
56+
type = "FIREWALL"
5657
}
58+
5759
resource "google_compute_organization_security_policy_rule" "policy" {
5860
policy_id = google_compute_organization_security_policy.policy.id
5961
action = "allow"
@@ -88,6 +90,7 @@ resource "google_folder" "security_policy_target" {
8890
resource "google_compute_organization_security_policy" "policy" {
8991
display_name = "tf-test%{random_suffix}"
9092
parent = google_folder.security_policy_target.name
93+
type = "FIREWALL"
9194
}
9295

9396
resource "google_compute_organization_security_policy_rule" "policy" {

mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_test.go.tmpl renamed to mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package compute_test
2-
{{- if ne $.TargetVersionName "ga" }}
32

43
import (
54
"testing"
5+
66
"github.com/hashicorp/terraform-provider-google/google/acctest"
77
"github.com/hashicorp/terraform-provider-google/google/envvar"
88

@@ -25,21 +25,21 @@ func TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdateEx
2525
{
2626
Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPreUpdateExample(context),
2727
},
28-
{
29-
ResourceName: "google_compute_organization_security_policy.policy",
30-
ImportState: true,
31-
ImportStateVerify: true,
32-
ImportStateVerifyIgnore: []string{"display_name"},
33-
},
34-
{
28+
{
29+
ResourceName: "google_compute_organization_security_policy.policy",
30+
ImportState: true,
31+
ImportStateVerify: true,
32+
ImportStateVerifyIgnore: []string{"display_name", "parent"},
33+
},
34+
{
3535
Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPostUpdateExample(context),
36-
},
37-
{
38-
ResourceName: "google_compute_organization_security_policy.policy",
39-
ImportState: true,
40-
ImportStateVerify: true,
41-
ImportStateVerifyIgnore: []string{"display_name"},
42-
},
36+
},
37+
{
38+
ResourceName: "google_compute_organization_security_policy.policy",
39+
ImportState: true,
40+
ImportStateVerify: true,
41+
ImportStateVerifyIgnore: []string{"display_name", "parent"},
42+
},
4343
},
4444
})
4545
}
@@ -59,9 +59,10 @@ func TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyShortNam
5959
Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyShortName(context),
6060
},
6161
{
62-
ResourceName: "google_compute_organization_security_policy.policy",
63-
ImportState: true,
64-
ImportStateVerify: true,
62+
ResourceName: "google_compute_organization_security_policy.policy",
63+
ImportState: true,
64+
ImportStateVerify: true,
65+
ImportStateVerifyIgnore: []string{"display_name", "parent"},
6566
},
6667
},
6768
})
@@ -70,18 +71,18 @@ func TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyShortNam
7071
func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPreUpdateExample(context map[string]interface{}) string {
7172
return acctest.Nprintf(`
7273
resource "google_compute_organization_security_policy" "policy" {
73-
display_name = "tf-test%{random_suffix}"
74-
parent = "organizations/%{org_id}"
74+
short_name = "tf-test%{random_suffix}"
75+
parent = "organizations/%{org_id}"
7576
}
7677
`, context)
7778
}
7879

7980
func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPostUpdateExample(context map[string]interface{}) string {
8081
return acctest.Nprintf(`
8182
resource "google_compute_organization_security_policy" "policy" {
82-
display_name = "tf-test%{random_suffix}"
83-
parent = "organizations/%{org_id}"
84-
description = "Updated description."
83+
short_name = "tf-test%{random_suffix}"
84+
parent = "organizations/%{org_id}"
85+
description = "Updated description."
8586
}
8687
`, context)
8788
}
@@ -96,4 +97,3 @@ resource "google_compute_organization_security_policy" "policy" {
9697
}
9798
`, context)
9899
}
99-
{{- end }}

0 commit comments

Comments
 (0)