Skip to content

Commit 014622c

Browse files
authored
Merge branch 'master' into fix/add-local-deployment-instructions
2 parents 638a889 + a07e6a0 commit 014622c

File tree

7 files changed

+49
-56
lines changed

7 files changed

+49
-56
lines changed

3-networks-dual-svpc/modules/hierarchical_firewall_policy/main.tf

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
locals {
18-
policy_id = google_compute_organization_security_policy.policy.id
18+
policy_id = google_compute_firewall_policy.policy.id
1919
}
2020

2121
resource "random_string" "suffix" {
@@ -24,17 +24,15 @@ resource "random_string" "suffix" {
2424
special = false
2525
}
2626

27-
resource "google_compute_organization_security_policy" "policy" {
28-
provider = google-beta
29-
display_name = "${var.name}-${random_string.suffix.result}"
30-
parent = var.parent
27+
resource "google_compute_firewall_policy" "policy" {
28+
short_name = "${var.name}-${random_string.suffix.result}"
29+
parent = var.parent
3130
}
3231

33-
resource "google_compute_organization_security_policy_rule" "rule" {
34-
provider = google-beta
32+
resource "google_compute_firewall_policy_rule" "rule" {
3533
for_each = var.rules
3634

37-
policy_id = google_compute_organization_security_policy.policy.id
35+
firewall_policy = google_compute_firewall_policy.policy.id
3836
action = each.value.action
3937
direction = each.value.direction
4038
priority = each.value.priority
@@ -44,25 +42,24 @@ resource "google_compute_organization_security_policy_rule" "rule" {
4442
# preview = each.value.preview
4543
match {
4644
# description = each.value.description
47-
config {
48-
src_ip_ranges = each.value.direction == "INGRESS" ? each.value.ranges : null
49-
dest_ip_ranges = each.value.direction == "EGRESS" ? each.value.ranges : null
50-
dynamic "layer4_config" {
51-
for_each = each.value.ports
52-
iterator = port
53-
content {
54-
ip_protocol = port.key
55-
ports = port.value
56-
}
45+
46+
src_ip_ranges = each.value.direction == "INGRESS" ? each.value.ranges : null
47+
dest_ip_ranges = each.value.direction == "EGRESS" ? each.value.ranges : null
48+
dynamic "layer4_configs" {
49+
for_each = each.value.ports
50+
iterator = port
51+
content {
52+
ip_protocol = port.key
53+
ports = port.value
5754
}
5855
}
5956
}
6057
}
6158

62-
resource "google_compute_organization_security_policy_association" "association" {
63-
provider = google-beta
64-
for_each = toset(var.associations)
65-
name = "${local.policy_id}-${each.value}"
66-
policy_id = local.policy_id
67-
attachment_id = each.value
59+
resource "google_compute_firewall_policy_association" "association" {
60+
for_each = toset(var.associations)
61+
62+
name = replace("${local.policy_id}-${each.value}", "/", "-")
63+
firewall_policy = google_compute_firewall_policy.policy.id
64+
attachment_target = each.value
6865
}

3-networks-dual-svpc/modules/hierarchical_firewall_policy/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
*/
1616

1717
output "id" {
18-
value = google_compute_organization_security_policy.policy.id
18+
value = google_compute_firewall_policy.policy.id
1919
}

3-networks-dual-svpc/modules/hierarchical_firewall_policy/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ terraform {
1919
required_providers {
2020
google = {
2121
source = "hashicorp/google"
22-
version = ">= 3.50"
22+
version = ">= 3.82"
2323
}
2424
google-beta = {
2525
source = "hashicorp/google-beta"
26-
version = ">= 3.50"
26+
version = ">= 3.82"
2727
}
2828
random = {
2929
source = "hashicorp/random"

3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/main.tf

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
locals {
18-
policy_id = google_compute_organization_security_policy.policy.id
18+
policy_id = google_compute_firewall_policy.policy.id
1919
}
2020

2121
resource "random_string" "suffix" {
@@ -24,17 +24,15 @@ resource "random_string" "suffix" {
2424
special = false
2525
}
2626

27-
resource "google_compute_organization_security_policy" "policy" {
28-
provider = google-beta
29-
display_name = "${var.name}-${random_string.suffix.result}"
30-
parent = var.parent
27+
resource "google_compute_firewall_policy" "policy" {
28+
short_name = "${var.name}-${random_string.suffix.result}"
29+
parent = var.parent
3130
}
3231

33-
resource "google_compute_organization_security_policy_rule" "rule" {
34-
provider = google-beta
32+
resource "google_compute_firewall_policy_rule" "rule" {
3533
for_each = var.rules
3634

37-
policy_id = google_compute_organization_security_policy.policy.id
35+
firewall_policy = google_compute_firewall_policy.policy.id
3836
action = each.value.action
3937
direction = each.value.direction
4038
priority = each.value.priority
@@ -44,25 +42,24 @@ resource "google_compute_organization_security_policy_rule" "rule" {
4442
# preview = each.value.preview
4543
match {
4644
# description = each.value.description
47-
config {
48-
src_ip_ranges = each.value.direction == "INGRESS" ? each.value.ranges : null
49-
dest_ip_ranges = each.value.direction == "EGRESS" ? each.value.ranges : null
50-
dynamic "layer4_config" {
51-
for_each = each.value.ports
52-
iterator = port
53-
content {
54-
ip_protocol = port.key
55-
ports = port.value
56-
}
45+
46+
src_ip_ranges = each.value.direction == "INGRESS" ? each.value.ranges : null
47+
dest_ip_ranges = each.value.direction == "EGRESS" ? each.value.ranges : null
48+
dynamic "layer4_configs" {
49+
for_each = each.value.ports
50+
iterator = port
51+
content {
52+
ip_protocol = port.key
53+
ports = port.value
5754
}
5855
}
5956
}
6057
}
6158

62-
resource "google_compute_organization_security_policy_association" "association" {
63-
provider = google-beta
64-
for_each = toset(var.associations)
65-
name = "${local.policy_id}-${each.value}"
66-
policy_id = local.policy_id
67-
attachment_id = each.value
59+
resource "google_compute_firewall_policy_association" "association" {
60+
for_each = toset(var.associations)
61+
62+
name = replace("${local.policy_id}-${each.value}", "/", "-")
63+
firewall_policy = google_compute_firewall_policy.policy.id
64+
attachment_target = each.value
6865
}

3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
*/
1616

1717
output "id" {
18-
value = google_compute_organization_security_policy.policy.id
18+
value = google_compute_firewall_policy.policy.id
1919
}

3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ terraform {
1919
required_providers {
2020
google = {
2121
source = "hashicorp/google"
22-
version = ">= 3.50"
22+
version = ">= 3.82"
2323
}
2424
google-beta = {
2525
source = "hashicorp/google-beta"
26-
version = ">= 3.50"
26+
version = ">= 3.82"
2727
}
2828
random = {
2929
source = "hashicorp/random"

test/integration/org/org_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ func TestOrg(t *testing.T) {
222222
assert.Equal(billingDatasetFullName, billingDataset.Get("id").String(), fmt.Sprintf("dataset %s should exist", billingDatasetFullName))
223223

224224
auditLogsProjectID := org.GetStringOutput("org_audit_logs_project_id")
225-
auditLogsProjectNumber := gcloud.Runf(t, "projects describe %s", auditLogsProjectID).Get("projectNumber").String()
226225

227226
// Bucket destination
228227
logsExportStorageBucketName := org.GetStringOutput("logs_export_storage_bucket_name")
@@ -247,7 +246,7 @@ func TestOrg(t *testing.T) {
247246
prjLinkedDsName := org.GetStringOutput("logs_export_project_linked_dataset_name")
248247
prjLinkedDs := gcloud.Runf(t, "logging links describe %s --bucket=%s --location=%s --project=%s", prjLinkedDatasetID, prjLogsExportLogBktName, defaultRegion, auditLogsProjectID)
249248
assert.Equal(prjLinkedDsName, prjLinkedDs.Get("name").String(), "log bucket linked dataset name should match")
250-
prjBigqueryDatasetID := fmt.Sprintf("bigquery.googleapis.com/projects/%s/datasets/%s", auditLogsProjectNumber, prjLinkedDatasetID)
249+
prjBigqueryDatasetID := fmt.Sprintf("bigquery.googleapis.com/projects/%s/datasets/%s", auditLogsProjectID, prjLinkedDatasetID)
251250
assert.Equal(prjBigqueryDatasetID, prjLinkedDs.Get("bigqueryDataset.datasetId").String(), "log bucket BigQuery dataset ID should match")
252251

253252
// add filter exclusion

0 commit comments

Comments
 (0)