Update service activation in ngfw add-on (#2823)

* align services use in ngfw add-on with swp

* update ngfw README example
This commit is contained in:
Ludovico Magnocavallo
2025-01-18 14:23:23 +01:00
committed by GitHub
parent 0b6bcdccf8
commit 1c2e3c5677
6 changed files with 41 additions and 20 deletions

View File

@@ -110,10 +110,6 @@ certificate_authorities = {
}
}
}
ca_pool_config = {
authz_nsec_sa = true
name = "ca-pool-0"
}
}
}
ngfw_config = {
@@ -210,16 +206,18 @@ Security profiles group defined here are exported via output variable file, and
| name | description | type | required | default | producer |
|---|---|:---:|:---:|:---:|:---:|
| [automation](variables-fast.tf#L28) | Automation resources created by the bootstrap stage. | <code title="object&#40;&#123;&#10; outputs_bucket &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | <code>0-bootstrap</code> |
| [ngfw_config](variables.tf#L106) | Configuration for NGFW Enterprise endpoints. Billing project defaults to the automation project. Network and TLS inspection policy ids support interpolation. | <code title="object&#40;&#123;&#10; endpoint_zones &#61; list&#40;string&#41;&#10; name &#61; optional&#40;string, &#34;ngfw-0&#34;&#41;&#10; network_associations &#61; optional&#40;map&#40;object&#40;&#123;&#10; vpc_id &#61; string&#10; disabled &#61; optional&#40;bool&#41;&#10; tls_inspection_policy &#61; optional&#40;string&#41;&#10; zones &#61; optional&#40;list&#40;string&#41;&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | |
| [organization](variables-fast.tf#L48) | Organization details. | <code title="object&#40;&#123;&#10; domain &#61; string&#10; id &#61; number&#10; customer_id &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | <code>0-globals</code> |
| [project_id](variables.tf#L127) | Project where the network security resources will be created. | <code>string</code> | ✓ | | |
| [ngfw_config](variables.tf#L113) | Configuration for NGFW Enterprise endpoints. Billing project defaults to the automation project. Network and TLS inspection policy ids support interpolation. | <code title="object&#40;&#123;&#10; endpoint_zones &#61; list&#40;string&#41;&#10; name &#61; optional&#40;string, &#34;ngfw-0&#34;&#41;&#10; network_associations &#61; optional&#40;map&#40;object&#40;&#123;&#10; vpc_id &#61; string&#10; disabled &#61; optional&#40;bool&#41;&#10; tls_inspection_policy &#61; optional&#40;string&#41;&#10; zones &#61; optional&#40;list&#40;string&#41;&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | |
| [organization](variables-fast.tf#L56) | Organization details. | <code title="object&#40;&#123;&#10; domain &#61; string&#10; id &#61; number&#10; customer_id &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | <code>0-globals</code> |
| [project_id](variables.tf#L134) | Project where the network security resources will be created. | <code>string</code> | ✓ | | |
| [_fast_debug](variables-fast.tf#L19) | Internal FAST variable used for testing and debugging. Do not use. | <code title="object&#40;&#123;&#10; skip_datasources &#61; optional&#40;bool, false&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> | |
| [certificate_authorities](variables.tf#L17) | Certificate Authority Service pool and CAs. If host project ids is null identical pools and CAs are created in every host project. | <code title="map&#40;object&#40;&#123;&#10; location &#61; string&#10; iam &#61; optional&#40;map&#40;list&#40;string&#41;&#41;, &#123;&#125;&#41;&#10; iam_bindings &#61; optional&#40;map&#40;any&#41;, &#123;&#125;&#41;&#10; iam_bindings_additive &#61; optional&#40;map&#40;any&#41;, &#123;&#125;&#41;&#10; iam_by_principals &#61; optional&#40;map&#40;list&#40;string&#41;&#41;, &#123;&#125;&#41;&#10; ca_configs &#61; map&#40;object&#40;&#123;&#10; deletion_protection &#61; optional&#40;string, true&#41;&#10; type &#61; optional&#40;string, &#34;SELF_SIGNED&#34;&#41;&#10; is_ca &#61; optional&#40;bool, true&#41;&#10; lifetime &#61; optional&#40;string, null&#41;&#10; pem_ca_certificate &#61; optional&#40;string, null&#41;&#10; ignore_active_certificates_on_deletion &#61; optional&#40;bool, false&#41;&#10; skip_grace_period &#61; optional&#40;bool, true&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;, null&#41;&#10; gcs_bucket &#61; optional&#40;string, null&#41;&#10; key_spec &#61; optional&#40;object&#40;&#123;&#10; algorithm &#61; optional&#40;string, &#34;RSA_PKCS1_2048_SHA256&#34;&#41;&#10; kms_key_id &#61; optional&#40;string, null&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10; key_usage &#61; optional&#40;object&#40;&#123;&#10; cert_sign &#61; optional&#40;bool, true&#41;&#10; client_auth &#61; optional&#40;bool, false&#41;&#10; code_signing &#61; optional&#40;bool, false&#41;&#10; content_commitment &#61; optional&#40;bool, false&#41;&#10; crl_sign &#61; optional&#40;bool, true&#41;&#10; data_encipherment &#61; optional&#40;bool, false&#41;&#10; decipher_only &#61; optional&#40;bool, false&#41;&#10; digital_signature &#61; optional&#40;bool, false&#41;&#10; email_protection &#61; optional&#40;bool, false&#41;&#10; encipher_only &#61; optional&#40;bool, false&#41;&#10; key_agreement &#61; optional&#40;bool, false&#41;&#10; key_encipherment &#61; optional&#40;bool, true&#41;&#10; ocsp_signing &#61; optional&#40;bool, false&#41;&#10; server_auth &#61; optional&#40;bool, true&#41;&#10; time_stamping &#61; optional&#40;bool, false&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10; subject &#61; optional&#40;&#10; object&#40;&#123;&#10; common_name &#61; string&#10; organization &#61; string&#10; country_code &#61; optional&#40;string&#41;&#10; locality &#61; optional&#40;string&#41;&#10; organizational_unit &#61; optional&#40;string&#41;&#10; postal_code &#61; optional&#40;string&#41;&#10; province &#61; optional&#40;string&#41;&#10; street_address &#61; optional&#40;string&#41;&#10; &#125;&#41;,&#10; &#123;&#10; common_name &#61; &#34;test.example.com&#34;&#10; organization &#61; &#34;Test Example&#34;&#10; &#125;&#10; &#41;&#10; subject_alt_name &#61; optional&#40;object&#40;&#123;&#10; dns_names &#61; optional&#40;list&#40;string&#41;, null&#41;&#10; email_addresses &#61; optional&#40;list&#40;string&#41;, null&#41;&#10; ip_addresses &#61; optional&#40;list&#40;string&#41;, null&#41;&#10; uris &#61; optional&#40;list&#40;string&#41;, null&#41;&#10; &#125;&#41;, null&#41;&#10; subordinate_config &#61; optional&#40;object&#40;&#123;&#10; root_ca_id &#61; optional&#40;string&#41;&#10; pem_issuer_certificates &#61; optional&#40;list&#40;string&#41;&#41;&#10; &#125;&#41;, null&#41;&#10; &#125;&#41;&#41;&#10; ca_pool_config &#61; optional&#40;object&#40;&#123;&#10; create_pool &#61; optional&#40;object&#40;&#123;&#10; name &#61; optional&#40;string&#41;&#10; tier &#61; optional&#40;string, &#34;DEVOPS&#34;&#41;&#10; &#125;&#41;&#41;&#10; use_pool &#61; optional&#40;object&#40;&#123;&#10; id &#61; string&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | |
| [certificate_authority_pools](variables-fast.tf#L36) | Certificate authority pools. | <code title="map&#40;object&#40;&#123;&#10; id &#61; string&#10; ca_ids &#61; map&#40;string&#41;&#10; location &#61; string&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | <code>2-security</code> |
| [names](variables.tf#L97) | Configuration for names used for output files. | <code title="object&#40;&#123;&#10; output_files_prefix &#61; optional&#40;string, &#34;2-networking-ngfw&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> | |
| [outputs_location](variables.tf#L121) | Path where providers and tfvars files for the following stages are written. Leave empty to disable. | <code>string</code> | | <code>null</code> | |
| [security_profiles](variables.tf#L133) | Security profile groups for Layer 7 inspection. Null environment list means all environments. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string&#41;&#10; threat_prevention_profile &#61; optional&#40;object&#40;&#123;&#10; severity_overrides &#61; optional&#40;map&#40;object&#40;&#123;&#10; action &#61; string&#10; severity &#61; string&#10; &#125;&#41;&#41;&#41;&#10; threat_overrides &#61; optional&#40;map&#40;object&#40;&#123;&#10; action &#61; string&#10; threat_id &#61; string&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10; ngfw-default &#61; &#123;&#125;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [tls_inspection_policies](variables.tf#L175) | TLS inspection policies configuration. CA pools, trust configs and host project ids support interpolation. | <code title="map&#40;object&#40;&#123;&#10; ca_pool_id &#61; string&#10; location &#61; string&#10; exclude_public_ca_set &#61; optional&#40;bool&#41;&#10; trust_config &#61; optional&#40;string&#41;&#10; tls &#61; optional&#40;object&#40;&#123;&#10; custom_features &#61; optional&#40;list&#40;string&#41;&#41;&#10; feature_profile &#61; optional&#40;string&#41;&#10; min_version &#61; optional&#40;string&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | |
| [trust_configs](variables.tf#L217) | Certificate Manager trust configurations for TLS inspection policies. Project ids and region can reference keys in the relevant FAST variables. | <code title="map&#40;object&#40;&#123;&#10; location &#61; string&#10; description &#61; optional&#40;string&#41;&#10; allowlisted_certificates &#61; optional&#40;map&#40;string&#41;&#41;&#10; trust_stores &#61; optional&#40;map&#40;object&#40;&#123;&#10; intermediate_cas &#61; optional&#40;map&#40;string&#41;&#41;&#10; trust_anchors &#61; optional&#40;map&#40;string&#41;&#41;&#10; &#125;&#41;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [vpc_self_links](variables-fast.tf#L58) | VPC network self links. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> | <code>2-networking</code> |
| [enable_services](variables.tf#L97) | Configure project by enabling services required for this add-on. | <code>bool</code> | | <code>true</code> | |
| [host_project_ids](variables-fast.tf#L48) | Networking stage host project id aliases. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> | <code>2-networking</code> |
| [names](variables.tf#L104) | Configuration for names used for output files. | <code title="object&#40;&#123;&#10; output_files_prefix &#61; optional&#40;string, &#34;2-networking-ngfw&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> | |
| [outputs_location](variables.tf#L128) | Path where providers and tfvars files for the following stages are written. Leave empty to disable. | <code>string</code> | | <code>null</code> | |
| [security_profiles](variables.tf#L140) | Security profile groups for Layer 7 inspection. Null environment list means all environments. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string&#41;&#10; threat_prevention_profile &#61; optional&#40;object&#40;&#123;&#10; severity_overrides &#61; optional&#40;map&#40;object&#40;&#123;&#10; action &#61; string&#10; severity &#61; string&#10; &#125;&#41;&#41;&#41;&#10; threat_overrides &#61; optional&#40;map&#40;object&#40;&#123;&#10; action &#61; string&#10; threat_id &#61; string&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10; ngfw-default &#61; &#123;&#125;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [tls_inspection_policies](variables.tf#L182) | TLS inspection policies configuration. CA pools, trust configs and host project ids support interpolation. | <code title="map&#40;object&#40;&#123;&#10; ca_pool_id &#61; string&#10; location &#61; string&#10; exclude_public_ca_set &#61; optional&#40;bool&#41;&#10; trust_config &#61; optional&#40;string&#41;&#10; tls &#61; optional&#40;object&#40;&#123;&#10; custom_features &#61; optional&#40;list&#40;string&#41;&#41;&#10; feature_profile &#61; optional&#40;string&#41;&#10; min_version &#61; optional&#40;string&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | |
| [trust_configs](variables.tf#L224) | Certificate Manager trust configurations for TLS inspection policies. Project ids and region can reference keys in the relevant FAST variables. | <code title="map&#40;object&#40;&#123;&#10; location &#61; string&#10; description &#61; optional&#40;string&#41;&#10; allowlisted_certificates &#61; optional&#40;map&#40;string&#41;&#41;&#10; trust_stores &#61; optional&#40;map&#40;object&#40;&#123;&#10; intermediate_cas &#61; optional&#40;map&#40;string&#41;&#41;&#10; trust_anchors &#61; optional&#40;map&#40;string&#41;&#41;&#10; &#125;&#41;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [vpc_self_links](variables-fast.tf#L66) | VPC network self links. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> | <code>2-networking</code> |
<!-- END TFDOC -->

View File

@@ -15,15 +15,23 @@
*/
locals {
aliased_project_id = lookup(
var.host_project_ids, var.project_id, var.project_id
)
project_id = try(module.project[0].project_id, var.project_id)
}
module "project" {
source = "../../../modules/project"
count = var._fast_debug.skip_datasources == true ? 0 : 1
name = var.project_id
name = local.aliased_project_id
project_create = false
services = [
service_agents_config = {
services_enabled = [
"networksecurity.googleapis.com"
]
}
services = var.enable_services != true ? [] : [
"certificatemanager.googleapis.com",
"networkmanagement.googleapis.com",
"networksecurity.googleapis.com",

View File

@@ -45,7 +45,7 @@ module "cas" {
iam_bindings_additive = merge(
each.value.iam_bindings_additive,
var._fast_debug.skip_datasources == true ? {} : {
nsec_agent = {
nsec_certificate_manager = {
member = module.project[0].service_agents["networksecurity"].iam_email
role = "roles/privateca.certificateManager"
}

View File

@@ -45,6 +45,14 @@ variable "certificate_authority_pools" {
default = {}
}
variable "host_project_ids" {
# tfdoc:variable:source 2-networking
description = "Networking stage host project id aliases."
type = map(string)
nullable = false
default = {}
}
variable "organization" {
# tfdoc:variable:source 0-globals
description = "Organization details."

View File

@@ -94,6 +94,13 @@ variable "certificate_authorities" {
default = {}
}
variable "enable_services" {
description = "Configure project by enabling services required for this add-on."
type = bool
nullable = false
default = true
}
variable "names" {
description = "Configuration for names used for output files."
type = object({

View File

@@ -37,10 +37,10 @@ module "cas" {
iam_bindings_additive = merge(
var.certificate_authority.iam_bindings_additive,
var._fast_debug.skip_datasources == true ? {} : {
# nsec_certificate_manager = {
# member = module.project[0].service_agents["networksecurity"].iam_email
# role = "roles/privateca.certificateManager"
# }
nsec_certificate_manager = {
member = module.project[0].service_agents["networksecurity"].iam_email
role = "roles/privateca.certificateManager"
}
}
)
}