|
| 1 | +data "google_project" "project" { |
| 2 | + provider = google-beta |
| 3 | +} |
| 4 | + |
| 5 | +resource "google_compute_network_firewall_policy_with_rules" "<%= ctx[:primary_resource_id] %>" { |
| 6 | + name = "<%= ctx[:vars]['policy_name'] %>" |
| 7 | + description = "Terraform test" |
| 8 | + provider = google-beta |
| 9 | + |
| 10 | + rule { |
| 11 | + description = "tcp rule" |
| 12 | + priority = 1000 |
| 13 | + enable_logging = true |
| 14 | + action = "allow" |
| 15 | + direction = "EGRESS" |
| 16 | + match { |
| 17 | + layer4_config { |
| 18 | + ip_protocol = "tcp" |
| 19 | + ports = [8080, 7070] |
| 20 | + } |
| 21 | + dest_ip_ranges = ["11.100.0.1/32"] |
| 22 | + dest_fqdns = ["www.yyy.com", "www.zzz.com"] |
| 23 | + dest_region_codes = ["HK", "IN"] |
| 24 | + dest_threat_intelligences = ["iplist-search-engines-crawlers", "iplist-tor-exit-nodes"] |
| 25 | + dest_address_groups = [google_network_security_address_group.address_group_1.id] |
| 26 | + } |
| 27 | + target_secure_tag { |
| 28 | + name = "tagValues/${google_tags_tag_value.secure_tag_value_1.name}" |
| 29 | + } |
| 30 | + } |
| 31 | + rule { |
| 32 | + description = "udp rule" |
| 33 | + priority = 2000 |
| 34 | + enable_logging = false |
| 35 | + action = "deny" |
| 36 | + direction = "INGRESS" |
| 37 | + match { |
| 38 | + layer4_config { |
| 39 | + ip_protocol = "udp" |
| 40 | + } |
| 41 | + src_ip_ranges = ["0.0.0.0/0"] |
| 42 | + src_fqdns = ["www.abc.com", "www.def.com"] |
| 43 | + src_region_codes = ["US", "CA"] |
| 44 | + src_threat_intelligences = ["iplist-known-malicious-ips", "iplist-public-clouds"] |
| 45 | + src_address_groups = [google_network_security_address_group.address_group_1.id] |
| 46 | + src_secure_tag { |
| 47 | + name = "tagValues/${google_tags_tag_value.secure_tag_value_1.name}" |
| 48 | + } |
| 49 | + } |
| 50 | + disabled = true |
| 51 | + } |
| 52 | + |
| 53 | + rule { |
| 54 | + description = "security profile group rule" |
| 55 | + rule_name = "tcp rule" |
| 56 | + priority = 3000 |
| 57 | + enable_logging = false |
| 58 | + action = "apply_security_profile_group" |
| 59 | + direction = "INGRESS" |
| 60 | + match { |
| 61 | + layer4_config { |
| 62 | + ip_protocol = "tcp" |
| 63 | + } |
| 64 | + src_ip_ranges = ["0.0.0.0/0"] |
| 65 | + } |
| 66 | + target_service_accounts = [" [email protected]"] |
| 67 | + security_profile_group = "//networksecurity.googleapis.com/${google_network_security_security_profile_group.security_profile_group_1.id}" |
| 68 | + tls_inspect = true |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +resource "google_network_security_address_group" "address_group_1" { |
| 73 | + provider = google-beta |
| 74 | + name = "<%= ctx[:vars]['address_group_name'] %>" |
| 75 | + parent = "projects/${data.google_project.project.name}" |
| 76 | + description = "Global address group" |
| 77 | + location = "global" |
| 78 | + items = ["208.80.154.224/32"] |
| 79 | + type = "IPV4" |
| 80 | + capacity = 100 |
| 81 | +} |
| 82 | + |
| 83 | +resource "google_tags_tag_key" "secure_tag_key_1" { |
| 84 | + provider = google-beta |
| 85 | + description = "Tag key" |
| 86 | + parent = "projects/${data.google_project.project.name}" |
| 87 | + purpose = "GCE_FIREWALL" |
| 88 | + short_name = "<%= ctx[:vars]['tag_key_name'] %>" |
| 89 | + purpose_data = { |
| 90 | + network = "${data.google_project.project.name}/default" |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +resource "google_tags_tag_value" "secure_tag_value_1" { |
| 95 | + provider = google-beta |
| 96 | + description = "Tag value" |
| 97 | + parent = "tagKeys/${google_tags_tag_key.secure_tag_key_1.name}" |
| 98 | + short_name = "<%= ctx[:vars]['tag_value_name'] %>" |
| 99 | +} |
| 100 | + |
| 101 | +resource "google_network_security_security_profile_group" "security_profile_group_1" { |
| 102 | + provider = google-beta |
| 103 | + name = "<%= ctx[:vars]['security_profile_group_name'] %>" |
| 104 | + parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" |
| 105 | + description = "my description" |
| 106 | + threat_prevention_profile = google_network_security_security_profile.security_profile_1.id |
| 107 | +} |
| 108 | + |
| 109 | +resource "google_network_security_security_profile" "security_profile_1" { |
| 110 | + provider = google-beta |
| 111 | + name = "<%= ctx[:vars]['security_profile_name'] %>" |
| 112 | + type = "THREAT_PREVENTION" |
| 113 | + parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" |
| 114 | + location = "global" |
| 115 | +} |
| 116 | + |
0 commit comments