From 4c0f636336a733994b89d845549ff2a4d149808c Mon Sep 17 00:00:00 2001 From: ghabian Date: Thu, 10 Nov 2022 19:01:31 -0500 Subject: [PATCH] Add support for network_firewall_policy_association and region_network_firewall_policy_association (#6796) Co-authored-by: Riley Karson Co-authored-by: Ghaleb Al-habian --- .../network_firewall_policy_association.yaml | 33 +++++++++++++++++++ .../network_firewall_policy_association.yaml | 33 +++++++++++++++++++ .../global.tf.tmpl | 16 +++++++++ .../global.yaml | 11 +++++++ .../global_update.tf.tmpl | 20 +++++++++++ .../meta.yaml | 22 +++++++++++++ .../regional.tf.tmpl | 18 ++++++++++ .../regional.yaml | 13 ++++++++ .../regional_update.tf.tmpl | 22 +++++++++++++ 9 files changed, 188 insertions(+) create mode 100644 tpgtools/overrides/compute/beta/network_firewall_policy_association.yaml create mode 100644 tpgtools/overrides/compute/network_firewall_policy_association.yaml create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.tf.tmpl create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.yaml create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global_update.tf.tmpl create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/meta.yaml create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.tf.tmpl create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.yaml create mode 100644 tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional_update.tf.tmpl diff --git a/tpgtools/overrides/compute/beta/network_firewall_policy_association.yaml b/tpgtools/overrides/compute/beta/network_firewall_policy_association.yaml new file mode 100644 index 000000000000..8919dd2c7cf8 --- /dev/null +++ b/tpgtools/overrides/compute/beta/network_firewall_policy_association.yaml @@ -0,0 +1,33 @@ +- type: CUSTOM_RESOURCE_NAME + details: + title: region_network_firewall_policy_association + location: region +- type: EXCLUDE + field: location + location: global +- type: EXCLUDE + field: region +- type: CUSTOM_NAME + details: + name: region + field: location +- type: CUSTOM_ID + details: + id: "projects/{{project}}/regions/{{region}}/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + location: region +- type: CUSTOM_ID + details: + id: "projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + location: global +- type: IMPORT_FORMAT + details: + formats: + - "projects/{{project}}/regions/{{region}}/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + - "{{project}}/{{region}}/{{firewall_policy}}/{{name}}" + location: region +- type: IMPORT_FORMAT + details: + formats: + - "projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + - "{{project}}/{{firewall_policy}}/{{name}}" + location: global diff --git a/tpgtools/overrides/compute/network_firewall_policy_association.yaml b/tpgtools/overrides/compute/network_firewall_policy_association.yaml new file mode 100644 index 000000000000..8919dd2c7cf8 --- /dev/null +++ b/tpgtools/overrides/compute/network_firewall_policy_association.yaml @@ -0,0 +1,33 @@ +- type: CUSTOM_RESOURCE_NAME + details: + title: region_network_firewall_policy_association + location: region +- type: EXCLUDE + field: location + location: global +- type: EXCLUDE + field: region +- type: CUSTOM_NAME + details: + name: region + field: location +- type: CUSTOM_ID + details: + id: "projects/{{project}}/regions/{{region}}/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + location: region +- type: CUSTOM_ID + details: + id: "projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + location: global +- type: IMPORT_FORMAT + details: + formats: + - "projects/{{project}}/regions/{{region}}/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + - "{{project}}/{{region}}/{{firewall_policy}}/{{name}}" + location: region +- type: IMPORT_FORMAT + details: + formats: + - "projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}" + - "{{project}}/{{firewall_policy}}/{{name}}" + location: global diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.tf.tmpl b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.tf.tmpl new file mode 100644 index 000000000000..f02ab0b76ed9 --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.tf.tmpl @@ -0,0 +1,16 @@ +resource "google_compute_network_firewall_policy" "network_firewall_policy" { + name = "{{policy}}" + project = "{{project}}" + description = "Sample global network firewall policy" +} + +resource "google_compute_network" "network" { + name = "{{network}}" +} + +resource "google_compute_network_firewall_policy_association" "primary" { + name = "{{association}}" + attachment_target = google_compute_network.network.id + firewall_policy = google_compute_network_firewall_policy.network_firewall_policy.name + project = "{{project}}" +} diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.yaml b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.yaml new file mode 100644 index 000000000000..d9d94648aae7 --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global.yaml @@ -0,0 +1,11 @@ +updates: +- resource: ./global_update.tf.tmpl +variables: +- name: association + type: resource_name +- name: policy + type: resource_name +- name: network + type: resource_name +- name: project + type: project diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global_update.tf.tmpl b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global_update.tf.tmpl new file mode 100644 index 000000000000..05cb145b2f33 --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/global_update.tf.tmpl @@ -0,0 +1,20 @@ +resource "google_compute_network_firewall_policy" "network_firewall_policy" { + name = "{{policy}}" + project = "{{project}}" + description = "Sample global network firewall policy" +} + +resource "google_compute_network" "network" { + name = "{{network}}" +} + +resource "google_compute_network" "network2" { + name = "update-{{network}}" +} + +resource "google_compute_network_firewall_policy_association" "primary" { + name = "{{association}}" + attachment_target = google_compute_network.network2.id + firewall_policy = google_compute_network_firewall_policy.network_firewall_policy.name + project = "{{project}}" +} diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/meta.yaml b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/meta.yaml new file mode 100644 index 000000000000..cd9c3249496e --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/meta.yaml @@ -0,0 +1,22 @@ +# meta.yaml +# this is a shared config file that all the tests merge with +# +doc_hide: + - global_network_firewall_policy_association.yaml + - basic_regional_network_firewall_policy_association.yaml + +doc_hide_conditional: + - location: global + file_name: regional.tf.tmpl + - location: region + file_name: global.tf.tmpl + +test_hide: + - global_network_firewall_policy_association.yaml + - basic_regional_network_firewall_policy_association.yaml + +test_hide_conditional: + - location: global + file_name: regional.tf.tmpl + - location: region + file_name: global.tf.tmpl diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.tf.tmpl b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.tf.tmpl new file mode 100644 index 000000000000..29548370ab59 --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.tf.tmpl @@ -0,0 +1,18 @@ +resource "google_compute_region_network_firewall_policy" "basic_regional_network_firewall_policy" { + name = "{{policy}}" + project = "{{project}}" + description = "Sample global network firewall policy" + region = "{{region}}" +} + +resource "google_compute_network" "basic_network" { + name = "{{network}}" +} + +resource "google_compute_region_network_firewall_policy_association" "primary" { + name = "{{association}}" + attachment_target = google_compute_network.basic_network.id + firewall_policy = google_compute_region_network_firewall_policy.basic_regional_network_firewall_policy.name + project = "{{project}}" + region = "{{region}}" +} diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.yaml b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.yaml new file mode 100644 index 000000000000..c97bc51b9b0d --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional.yaml @@ -0,0 +1,13 @@ +updates: +- resource: ./regional_update.tf.tmpl +variables: +- name: association + type: resource_name +- name: policy + type: resource_name +- name: network + type: resource_name +- name: project + type: project +- name: region + type: region diff --git a/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional_update.tf.tmpl b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional_update.tf.tmpl new file mode 100644 index 000000000000..8a9f5a746a2a --- /dev/null +++ b/tpgtools/overrides/compute/samples/networkfirewallpolicyassociation/regional_update.tf.tmpl @@ -0,0 +1,22 @@ +resource "google_compute_region_network_firewall_policy" "basic_regional_network_firewall_policy" { + name = "{{policy}}" + project = "{{project}}" + description = "Sample global network firewall policy" + region = "{{region}}" +} + +resource "google_compute_network" "basic_network" { + name = "{{network}}" +} + +resource "google_compute_network" "basic_network2" { + name = "update-{{network}}" +} + +resource "google_compute_region_network_firewall_policy_association" "primary" { + name = "{{association}}" + attachment_target = google_compute_network.basic_network2.id + firewall_policy = google_compute_region_network_firewall_policy.basic_regional_network_firewall_policy.name + project = "{{project}}" + region = "{{region}}" +}