diff --git a/blueprints/data-solutions/README.md b/blueprints/data-solutions/README.md index 777d619d..3da4e7e9 100644 --- a/blueprints/data-solutions/README.md +++ b/blueprints/data-solutions/README.md @@ -66,6 +66,6 @@ This [blueprint](./vertex-mlops/) implements the infrastructure required to have ### Shielded Folder -This [blueprint](./shielded-folder/) implements an opinionated Folder configuration to implement GCP best practices. Configurations implemented on the folder would be beneficial to host Workloads inheriting constraints from the folder they belong to. +This [blueprint](./shielded-folder/) implements an opinionated folder configuration according to GCP best practices. Configurations implemented on the folder would be beneficial to host workloads inheriting constraints from the folder they belong to. -
\ No newline at end of file +
diff --git a/blueprints/data-solutions/shielded-folder/README.md b/blueprints/data-solutions/shielded-folder/README.md index eadd86c2..0d3fdb69 100644 --- a/blueprints/data-solutions/shielded-folder/README.md +++ b/blueprints/data-solutions/shielded-folder/README.md @@ -1,8 +1,8 @@ # Shielded folder -This blueprint implements an opinionated folder configuration to implement GCP best practices. Configurations implemented on the folder would be beneficial to host Workloads inheriting constraints from the folder they belong to. +This blueprint implements an opinionated folder configuration according to GCP best practices. Configurations at the folder level would be beneficial to host workloads inheriting constraints from the folder they belong to. -In this blueprint, a folder will be created implementing the following features: +In this blueprint, a folder will be created setting following features: - Organizational policies - Hierarchical firewall rules @@ -43,7 +43,7 @@ This separation into projects allows adhering to the least-privilege principle b User groups provide a stable frame of reference that allows decoupling the final set of permissions from the stage where entities and resources are created, and their IAM bindings are defined. -We use three groups to control access to resources: +We use groups to control access to resources: - `data-engineers`: They handle and run workloads on the `workload` subfolder. They have editor access to all resources in the `workload` folder in order to troubleshoot possible issues within the workload. This team can also impersonate any service account in the workload folder. - `data-security`: They handle security configurations for the shielded folder. They have owner access to the `audit-log` and `sec-core` projects. @@ -116,9 +116,9 @@ The shielded Folfer blueprint assumes [groups described](#user-groups) are creat ### Variable configuration PIPPO -There are three sets of variables you will need to fill in: +There are several sets of variables you will need to fill in: -```hcl +```tfvars access_policy_config = { access_policy_create = { parent = "organizations/1234567890123" @@ -136,10 +136,9 @@ organization = { id = "1122334455" } prefix = "prefix" -project_config_2 = { - billing_account_id = "123456-123456-123456" +project_config = { + billing_account_id = "123456-123456-123456" } -# tftest modules=8 resources=35 ``` ### Deploying the blueprint @@ -159,17 +158,17 @@ terraform apply | [access_policy_config](variables.tf#L17) | Provide 'access_policy_create' values if a folder scoped Access Policy creation is needed, uses existing 'policy_name' otherwise. Parent is in 'organizations/123456' format. Policy will be created scoped to the folder. | object({…}) | ✓ | | | [folder_config](variables.tf#L49) | Provide 'folder_create' values if folder creation is needed, uses existing 'folder_id' otherwise. Parent is in 'folders/nnn' or 'organizations/nnn' format. | object({…}) | ✓ | | | [organization](variables.tf#L124) | Organization details. | object({…}) | ✓ | | -| [prefix](variables.tf#L132) | Prefix used for resources that need unique names. Use 9 characters or less. | string | ✓ | | -| [project_config](variables.tf#L141) | Provide 'billing_account_id' value if project creation is needed, uses existing 'projects_id' if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | object({…}) | ✓ | | +| [prefix](variables.tf#L132) | Prefix used for resources that need unique names. | string | ✓ | | +| [project_config](variables.tf#L137) | Provide 'billing_account_id' value if project creation is needed, uses existing 'project_ids' if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | object({…}) | ✓ | | | [data_dir](variables.tf#L29) | Relative path for the folder storing configuration data. | string | | "data" | | [enable_features](variables.tf#L35) | Flag to enable features on the solution. | object({…}) | | {…} | | [groups](variables.tf#L61) | User groups. | object({…}) | | {} | | [kms_keys](variables.tf#L71) | KMS keys to create, keyed by name. | map(object({…})) | | {} | | [log_locations](variables.tf#L82) | Optional locations for GCS, BigQuery, and logging buckets created here. | object({…}) | | {…} | | [log_sinks](variables.tf#L99) | Org-level log sinks, in name => {type, filter} format. | map(object({…})) | | {…} | -| [vpc_sc_access_levels](variables.tf#L157) | VPC SC access level definitions. | map(object({…})) | | {} | -| [vpc_sc_egress_policies](variables.tf#L186) | VPC SC egress policy defnitions. | map(object({…})) | | {} | -| [vpc_sc_ingress_policies](variables.tf#L206) | VPC SC ingress policy defnitions. | map(object({…})) | | {} | +| [vpc_sc_access_levels](variables.tf#L153) | VPC SC access level definitions. | map(object({…})) | | {} | +| [vpc_sc_egress_policies](variables.tf#L182) | VPC SC egress policy defnitions. | map(object({…})) | | {} | +| [vpc_sc_ingress_policies](variables.tf#L202) | VPC SC ingress policy defnitions. | map(object({…})) | | {} | ## Outputs diff --git a/blueprints/data-solutions/shielded-folder/variables.tf b/blueprints/data-solutions/shielded-folder/variables.tf index 22fd76be..07084645 100644 --- a/blueprints/data-solutions/shielded-folder/variables.tf +++ b/blueprints/data-solutions/shielded-folder/variables.tf @@ -35,12 +35,12 @@ variable "data_dir" { variable "enable_features" { description = "Flag to enable features on the solution." type = object({ - encryption = optional(bool, true) + encryption = optional(bool, false) log_sink = optional(bool, true) vpc_sc = optional(bool, true) }) default = { - encryption = true + encryption = false log_sink = true vpc_sc = true } @@ -130,16 +130,12 @@ variable "organization" { } variable "prefix" { - description = "Prefix used for resources that need unique names. Use 9 characters or less." + description = "Prefix used for resources that need unique names." type = string - validation { - condition = try(length(var.prefix), 0) < 10 - error_message = "Use a maximum of 9 characters for prefix." - } } variable "project_config" { - description = "Provide 'billing_account_id' value if project creation is needed, uses existing 'projects_id' if null. Parent is in 'folders/nnn' or 'organizations/nnn' format." + description = "Provide 'billing_account_id' value if project creation is needed, uses existing 'project_ids' if null. Parent is in 'folders/nnn' or 'organizations/nnn' format." type = object({ billing_account_id = optional(string, null) project_ids = optional(object({ diff --git a/tests/blueprints/data_solutions/shielded_folder/simple.yaml b/tests/blueprints/data_solutions/shielded_folder/simple.yaml index acfe8168..244dcb97 100644 --- a/tests/blueprints/data_solutions/shielded_folder/simple.yaml +++ b/tests/blueprints/data_solutions/shielded_folder/simple.yaml @@ -12,121 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -# values: -# module.folder-workload.google_folder.folder[0]: -# display_name: prefix-workload -# timeouts: null -# module.folder.google_bigquery_dataset_iam_member.bq-sinks-binding["audit-logs"]: -# condition: [] -# role: roles/bigquery.dataEditor -# module.folder.google_bigquery_dataset_iam_member.bq-sinks-binding["vpc-sc"]: -# condition: [] -# role: roles/bigquery.dataEditor -# module.folder.google_folder.folder[0]: -# display_name: ShieldedMVP -# parent: organizations/1054601055974 -# timeouts: null -# module.folder.google_folder_iam_binding.authoritative["roles/editor"]: -# condition: [] -# members: -# - group:gcp-data-engineers@example.com -# role: roles/editor -# module.folder.google_logging_folder_sink.sink["audit-logs"]: -# description: audit-logs (Terraform-managed). -# disabled: false -# exclusions: [] -# filter: logName:"/logs/cloudaudit.googleapis.com%2Factivity" OR logName:"/logs/cloudaudit.googleapis.com%2Fsystem_event" -# include_children: true -# name: audit-logs -# module.folder.google_logging_folder_sink.sink["vpc-sc"]: -# description: vpc-sc (Terraform-managed). -# disabled: false -# exclusions: [] -# filter: protoPayload.metadata.@type="type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata" -# include_children: true -# name: vpc-sc -# module.log-export-dataset[0].google_bigquery_dataset.default: -# dataset_id: prefix_audit_export -# default_encryption_configuration: -# - kms_key_name: 'false' -# default_partition_expiration_ms: null -# default_table_expiration_ms: null -# delete_contents_on_destroy: false -# description: Terraform managed. -# friendly_name: Audit logs export. -# location: EU -# max_time_travel_hours: null -# project: prefix-audit-logs -# timeouts: null -# module.log-export-project[0].data.google_bigquery_default_service_account.bq_sa[0]: -# project: prefix-audit-logs -# module.log-export-project[0].data.google_storage_project_service_account.gcs_sa[0]: -# project: prefix-audit-logs -# user_project: null -# module.log-export-project[0].google_project.project[0]: -# auto_create_network: false -# billing_account: 123456-123456-123456 -# labels: null -# name: prefix-audit-logs -# project_id: prefix-audit-logs -# skip_delete: false -# timeouts: null -# module.log-export-project[0].google_project_service.project_services["bigquery.googleapis.com"]: -# disable_dependent_services: false -# disable_on_destroy: false -# project: prefix-audit-logs -# service: bigquery.googleapis.com -# timeouts: null -# module.log-export-project[0].google_project_service.project_services["pubsub.googleapis.com"]: -# disable_dependent_services: false -# disable_on_destroy: false -# project: prefix-audit-logs -# service: pubsub.googleapis.com -# timeouts: null -# module.log-export-project[0].google_project_service.project_services["stackdriver.googleapis.com"]: -# disable_dependent_services: false -# disable_on_destroy: false -# project: prefix-audit-logs -# service: stackdriver.googleapis.com -# timeouts: null -# module.log-export-project[0].google_project_service.project_services["storage.googleapis.com"]: -# disable_dependent_services: false -# disable_on_destroy: false -# project: prefix-audit-logs -# service: storage.googleapis.com -# timeouts: null -# module.log-export-project[0].google_project_service_identity.jit_si["pubsub.googleapis.com"]: -# project: prefix-audit-logs -# service: pubsub.googleapis.com -# timeouts: null -# module.vpc-sc[0].google_access_context_manager_access_policy.default[0]: -# parent: organizations/1122334455 -# timeouts: null -# title: shielded-folder -# module.vpc-sc[0].google_access_context_manager_service_perimeter.regular["shielded"]: -# description: null -# perimeter_type: PERIMETER_TYPE_REGULAR -# spec: -# - access_levels: [] -# egress_policies: [] -# ingress_policies: -# - ingress_from: -# - identity_type: null -# sources: -# - access_level: '*' -# resource: null -# ingress_to: -# - operations: -# - method_selectors: [] -# service_name: '*' -# restricted_services: null -# vpc_accessible_services: -# - allowed_services: null -# enable_restriction: true -# status: [] -# timeouts: null -# title: shielded -# use_explicit_dry_run_spec: true +values: + module.folder.google_compute_firewall_policy.policy["prefix-fw-policy"]: + short_name: prefix-fw-policy + module.folder.google_folder.folder[0]: + display_name: ShieldedMVP + parent: organizations/1234567890123 + module.log-export-project[0].google_project.project[0]: + billing_account: 123456-123456-123456 + project_id: prefix-audit-logs + module.vpc-sc[0].google_access_context_manager_access_policy.default[0]: + parent: organizations/1122334455 + title: shielded-folder + module.vpc-sc[0].google_access_context_manager_service_perimeter.regular["shielded"]: + description: null + perimeter_type: PERIMETER_TYPE_REGULAR + title: shielded counts: google_access_context_manager_access_policy: 1 @@ -134,18 +35,17 @@ counts: google_bigquery_dataset: 1 google_bigquery_dataset_iam_member: 2 google_bigquery_default_service_account: 1 + google_compute_firewall_policy: 1 + google_compute_firewall_policy_rule: 4 google_folder: 2 google_folder_iam_binding: 2 - google_kms_crypto_key: 3 - google_kms_crypto_key_iam_member: 3 - google_kms_key_ring: 2 google_logging_folder_sink: 2 - google_project: 2 - google_project_iam_binding: 2 - google_project_service: 7 - google_project_service_identity: 2 + google_org_policy_policy: 12 + google_project: 1 + google_project_iam_binding: 1 + google_project_service: 4 + google_project_service_identity: 1 google_projects: 1 google_storage_project_service_account: 1 - modules: 8 - resources: 52 - \ No newline at end of file + modules: 5 + resources: 38