Skip to content

Commit

Permalink
Add support for network_firewall_policy_association and region_networ…
Browse files Browse the repository at this point in the history
…k_firewall_policy_association (GoogleCloudPlatform#6796)

Co-authored-by: Riley Karson <[email protected]>
Co-authored-by: Ghaleb Al-habian <[email protected]>
  • Loading branch information
3 people authored and googlerjk committed Nov 21, 2022
1 parent bcce8a5 commit 4c0f636
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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}}"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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}}"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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}}"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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}}"
}

0 comments on commit 4c0f636

Please sign in to comment.