Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions network_security/intercept/basic/consumer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,36 @@
* limitations under the License.
*/

data "google_project" "default" {
provider = google-beta
}
data "google_project" "default" {}

# In case the project is in a folder, extract the organization ID from it.
data "google_folder" "default" {
provider = google-beta
count = data.google_project.default.folder_id != "" ? 1 : 0
folder = data.google_project.default.folder_id
lookup_organization = true
}

data "google_organization" "default" {
provider = google-beta
organization = data.google_project.default.org_id != "" ? data.google_project.default.org_id : data.google_folder.default[0].organization
}

# [START networksecurity_intercept_basic_consumer]
# [START networksecurity_intercept_create_producer_network_tf]
resource "google_compute_network" "producer_network" {
provider = google-beta
name = "producer-network"
auto_create_subnetworks = false
}
# [END networksecurity_intercept_create_producer_network_tf]

# [START networksecurity_intercept_create_consumer_network_tf]
resource "google_compute_network" "consumer_network" {
provider = google-beta
name = "consumer-network"
auto_create_subnetworks = false
}
# [END networksecurity_intercept_create_consumer_network_tf]

# [START networksecurity_intercept_create_consumer_subnetwork_tf]
resource "google_compute_subnetwork" "consumer_subnet" {
provider = google-beta
name = "consumer-subnet"
region = "us-central1"
ip_cidr_range = "10.10.0.0/16"
Expand All @@ -60,7 +53,6 @@ resource "google_compute_subnetwork" "consumer_subnet" {

# [START networksecurity_intercept_create_producer_deployment_group_tf]
resource "google_network_security_intercept_deployment_group" "default" {
provider = google-beta
intercept_deployment_group_id = "intercept-deployment-group"
location = "global"
network = google_compute_network.producer_network.id
Expand All @@ -69,7 +61,6 @@ resource "google_network_security_intercept_deployment_group" "default" {

# [START networksecurity_intercept_create_endpoint_group_tf]
resource "google_network_security_intercept_endpoint_group" "default" {
provider = google-beta
intercept_endpoint_group_id = "intercept-endpoint-group"
location = "global"
intercept_deployment_group = google_network_security_intercept_deployment_group.default.id
Expand All @@ -78,7 +69,6 @@ resource "google_network_security_intercept_endpoint_group" "default" {

# [START networksecurity_intercept_create_endpoint_group_association_tf]
resource "google_network_security_intercept_endpoint_group_association" "default" {
provider = google-beta
intercept_endpoint_group_association_id = "intercept-endpoint-group-association"
location = "global"
network = google_compute_network.consumer_network.id
Expand All @@ -88,7 +78,6 @@ resource "google_network_security_intercept_endpoint_group_association" "default

# [START networksecurity_intercept_create_security_profile_tf]
resource "google_network_security_security_profile" "default" {
provider = google-beta
name = "security-profile"
type = "CUSTOM_INTERCEPT"
parent = "organizations/${data.google_organization.default.org_id}"
Expand All @@ -102,7 +91,6 @@ resource "google_network_security_security_profile" "default" {

# [START networksecurity_intercept_create_security_profile_group_tf]
resource "google_network_security_security_profile_group" "default" {
provider = google-beta
name = "security-profile-group"
parent = "organizations/${data.google_organization.default.org_id}"
location = "global"
Expand All @@ -112,14 +100,12 @@ resource "google_network_security_security_profile_group" "default" {

# [START networksecurity_intercept_create_firewall_policy_tf]
resource "google_compute_network_firewall_policy" "default" {
provider = google-beta
name = "firewall-policy"
name = "firewall-policy"
}
# [END networksecurity_intercept_create_firewall_policy_tf]

# [START networksecurity_intercept_create_firewall_policy_rule_tf]
resource "google_compute_network_firewall_policy_rule" "default" {
provider = google-beta
firewall_policy = google_compute_network_firewall_policy.default.name
priority = 1000
action = "apply_security_profile_group"
Expand All @@ -138,7 +124,6 @@ resource "google_compute_network_firewall_policy_rule" "default" {

# [START networksecurity_intercept_create_firewall_policy_association_tf]
resource "google_compute_network_firewall_policy_association" "default" {
provider = google-beta
name = "firewall-policy-assoc"
attachment_target = google_compute_network.consumer_network.id
firewall_policy = google_compute_network_firewall_policy.default.name
Expand Down
11 changes: 2 additions & 9 deletions network_security/intercept/basic/producer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
# [START networksecurity_intercept_basic_producer]
# [START networksecurity_intercept_create_network_tf]
resource "google_compute_network" "default" {
provider = google-beta
name = "producer-network"
auto_create_subnetworks = false
}
# [END networksecurity_intercept_create_network_tf]

# [START networksecurity_intercept_create_subnetwork_tf]
resource "google_compute_subnetwork" "default" {
provider = google-beta
name = "producer-subnet"
region = "us-central1"
ip_cidr_range = "10.1.0.0/16"
Expand All @@ -35,9 +33,8 @@ resource "google_compute_subnetwork" "default" {

# [START networksecurity_intercept_create_health_check_tf]
resource "google_compute_region_health_check" "default" {
provider = google-beta
name = "deploymnet-hc"
region = "us-central1"
name = "deploymnet-hc"
region = "us-central1"
http_health_check {
port = 80
}
Expand All @@ -46,7 +43,6 @@ resource "google_compute_region_health_check" "default" {

# [START networksecurity_intercept_create_backend_service_tf]
resource "google_compute_region_backend_service" "default" {
provider = google-beta
name = "deployment-svc"
region = "us-central1"
health_checks = [google_compute_region_health_check.default.id]
Expand All @@ -57,7 +53,6 @@ resource "google_compute_region_backend_service" "default" {

# [START networksecurity_intercept_create_forwarding_rule_tf]
resource "google_compute_forwarding_rule" "default" {
provider = google-beta
name = "deployment-fr"
region = "us-central1"
network = google_compute_network.default.name
Expand All @@ -71,7 +66,6 @@ resource "google_compute_forwarding_rule" "default" {

# [START networksecurity_intercept_create_deployment_group_tf]
resource "google_network_security_intercept_deployment_group" "default" {
provider = google-beta
intercept_deployment_group_id = "intercept-deployment-group"
location = "global"
network = google_compute_network.default.id
Expand All @@ -80,7 +74,6 @@ resource "google_network_security_intercept_deployment_group" "default" {

# [START networksecurity_intercept_create_deployment_tf]
resource "google_network_security_intercept_deployment" "default" {
provider = google-beta
intercept_deployment_id = "intercept-deployment"
location = "us-central1-a"
forwarding_rule = google_compute_forwarding_rule.default.id
Expand Down