146 lines
13 KiB
Markdown
146 lines
13 KiB
Markdown
# 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.
|
|
|
|
In this blueprint, a folder will be created implementing the following features:
|
|
- Organizational policies
|
|
- Hirarckical firewall rules
|
|
- Cloud KMS
|
|
- VPC-SC
|
|
|
|
Within the folder, the following projects will be created:
|
|
- 'audit-logs' where Audit Logs sink will be created
|
|
- 'sec-core' where Cloud KMS and Cloud Secret manager will be configured
|
|
|
|
|
|
The following diagram is a high-level reference of the resources created and managed here:
|
|
|
|

|
|
|
|
## Design overview and choices
|
|
|
|
Despite its simplicity, this blueprint implements the basics of a design that we've seen working well for various customers.
|
|
|
|
The approach adapts to different high-level requirements:
|
|
- IAM roles inheritance
|
|
- Organizational policies
|
|
- Audit log sink
|
|
- VPC Service Control
|
|
- Cloud KMS
|
|
|
|
## Project structure
|
|
The Shielded Folder blueprint is designed to rely on several projects:
|
|
- `audit-log`: to host Audit logging buckets and Audit log sync to GCS, BigQuery or PubSub
|
|
- `sec-core`: to host security-related resources such as Cloud KMS and Cloud Secrets Manager
|
|
|
|
This separation into projects allows adhering to the least-privilege principle by using project-level roles.
|
|
|
|
## User groups
|
|
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:
|
|
- `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.
|
|
|
|
## Encryption
|
|
The blueprint supports the configuration of an instance of Cloud KMS to handle encryption on the resources. The encryption is disabled by default, but you can enable it by configuring the `enable_features.encryption` variable.
|
|
|
|
The script will create keys to encrypt log sink buckets/datasets/topics in the specified regions. Configuring the `kms_keys` variable, you can create additional KMS keys needed by your workload.
|
|
|
|
## Customizations
|
|
|
|
### VPC Service Control
|
|
VPC Service Control is configured to have a Perimeter containing all projects within the folder. Additional projects you may add to the folder won't be automatically added to the perimeter, and a new `terraform apply` is needed to add the project to the perimeter.
|
|
|
|
The VPC SC configuration is set to dry-run mode, but switching to enforced mode is a simple operation involving modifying a few lines of code highlighted by ad-hoc comments.
|
|
|
|
Access level rules are not defined. Before moving the configuration to enforced mode, configure access policies to continue accessing resources from outside of the perimeter.
|
|
|
|
An access level based on the network range you are using to reach the console (e.g. Proxy IP, Internet connection, ...) is suggested. Example:
|
|
|
|
```
|
|
vpc_sc_access_levels = {
|
|
users = {
|
|
conditions = [
|
|
{ members = ["user:user1@example.com"] }
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
Alternatively, you can configure an access level based on the identity that needs to reach resources from outside the perimeter.
|
|
|
|
```
|
|
vpc_sc_access_levels = {
|
|
users = {
|
|
conditions = [
|
|
{ ip_subnetworks = ["101.101.101.0/24"] }
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
## How to run this script
|
|
To deploy this blueprint in your GCP organization, you will need
|
|
- a folder or organization where resources will be created
|
|
- a billing account that will be associated with the new projects
|
|
|
|
The Shielded Folder blueprint is meant to be executed by a Service Account (or a regular user) having this minimal set of permission:
|
|
- Billing account
|
|
- `roles/billing.user`
|
|
- Folder level
|
|
- `roles/resourcemanager.folderAdmin`
|
|
- `roles/resourcemanager.projectCreator`
|
|
|
|
The shielded Folfer blueprint assumes [groups described](#groups) are created in your GCP organization.
|
|
|
|
### Variable configuration
|
|
There are three sets of variables you will need to fill in:
|
|
```
|
|
organization = {
|
|
id = "12345678"
|
|
domain = "example.com"
|
|
}
|
|
prefix = "prefix"
|
|
```
|
|
|
|
### Deploying the blueprint
|
|
Once the configuration is complete, run the project factory by running
|
|
|
|
```bash
|
|
terraform init
|
|
terraform apply
|
|
```
|
|
<!-- BEGIN TFDOC -->
|
|
|
|
## Variables
|
|
|
|
| name | description | type | required | default |
|
|
|---|---|:---:|:---:|:---:|
|
|
| [organization](variables.tf#L129) | Organization details. | <code title="object({ domain = string id = string })">object({…})</code> | ✓ | |
|
|
| [prefix](variables.tf#L137) | Prefix used for resources that need unique names. Use 9 characters or less. | <code>string</code> | ✓ | |
|
|
| [access_policy](variables.tf#L17) | Access Policy name, set to null if creating one. | <code>string</code> | | <code>null</code> |
|
|
| [access_policy_create](variables.tf#L23) | Access Policy configuration, fill in to create. Parent is in 'organizations/123456' format. | <code title="object({ parent = string title = string scopes = optional(list(string)) })">object({…})</code> | | <code>null</code> |
|
|
| [data_dir](variables.tf#L33) | Relative path for the folder storing configuration data. | <code>string</code> | | <code>"data"</code> |
|
|
| [enable_features](variables.tf#L39) | Flag to enable features on the solution. | <code title="object({ encryption = bool log_sink = bool vpc_sc = bool })">object({…})</code> | | <code title="{ encryption = false log_sink = true vpc_sc = true }">{…}</code> |
|
|
| [folder_create](variables.tf#L52) | Provide values if folder creation is needed, uses existing folder if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object({ display_name = string parent = string })">object({…})</code> | | <code>null</code> |
|
|
| [folder_id](variables.tf#L61) | Folder ID in case you use folder_create=null. | <code>string</code> | | <code>null</code> |
|
|
| [groups](variables.tf#L67) | User groups. | <code>map(string)</code> | | <code title="{ workload-engineers = "gcp-data-engineers" workload-security = "gcp-data-security" }">{…}</code> |
|
|
| [kms_keys](variables.tf#L76) | KMS keys to create, keyed by name. | <code title="map(object({ iam = optional(map(list(string)), {}) labels = optional(map(string), {}) locations = optional(list(string), ["global", "europe", "europe-west1"]) rotation_period = optional(string, "7776000s") }))">map(object({…}))</code> | | <code>{}</code> |
|
|
| [log_locations](variables.tf#L87) | Optional locations for GCS, BigQuery, and logging buckets created here. | <code title="object({ bq = optional(string, "europe") storage = optional(string, "europe") logging = optional(string, "global") pubsub = optional(string, "global") })">object({…})</code> | | <code title="{ bq = "europe" storage = "europe" logging = "global" pubsub = null }">{…}</code> |
|
|
| [log_sinks](variables.tf#L104) | Org-level log sinks, in name => {type, filter} format. | <code title="map(object({ filter = string type = string }))">map(object({…}))</code> | | <code title="{ audit-logs = { filter = "logName:\"/logs/cloudaudit.googleapis.com%2Factivity\" OR logName:\"/logs/cloudaudit.googleapis.com%2Fsystem_event\"" type = "bigquery" } vpc-sc = { filter = "protoPayload.metadata.@type=\"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata\"" type = "bigquery" } }">{…}</code> |
|
|
| [projects_create](variables.tf#L147) | Provide values if projects creation is needed, uses existing project if null. Projects will be created in the shielded folder. | <code title="object({ billing_account_id = string })">object({…})</code> | | <code>null</code> |
|
|
| [projects_id](variables.tf#L155) | Project id, references existing projects if `projects_create` is null. Projects will be moved into the shielded folder. | <code title="object({ sec-core = string audit-logs = string })">object({…})</code> | | <code>null</code> |
|
|
| [vpc_sc_access_levels](variables.tf#L164) | VPC SC access level definitions. | <code title="map(object({ combining_function = optional(string) conditions = optional(list(object({ device_policy = optional(object({ allowed_device_management_levels = optional(list(string)) allowed_encryption_statuses = optional(list(string)) require_admin_approval = bool require_corp_owned = bool require_screen_lock = optional(bool) os_constraints = optional(list(object({ os_type = string minimum_version = optional(string) require_verified_chrome_os = optional(bool) }))) })) ip_subnetworks = optional(list(string), []) members = optional(list(string), []) negate = optional(bool) regions = optional(list(string), []) required_access_levels = optional(list(string), []) })), []) description = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
| [vpc_sc_egress_policies](variables.tf#L193) | VPC SC egress policy defnitions. | <code title="map(object({ from = object({ identity_type = optional(string, "ANY_IDENTITY") identities = optional(list(string)) }) to = object({ operations = optional(list(object({ method_selectors = optional(list(string)) service_name = string })), []) resources = optional(list(string)) resource_type_external = optional(bool, false) }) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
| [vpc_sc_ingress_policies](variables.tf#L213) | VPC SC ingress policy defnitions. | <code title="map(object({ from = object({ access_levels = optional(list(string), []) identity_type = optional(string) identities = optional(list(string)) resources = optional(list(string), []) }) to = object({ operations = optional(list(object({ method_selectors = optional(list(string)) service_name = string })), []) resources = optional(list(string)) }) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
## Outputs
|
|
|
|
| name | description | sensitive |
|
|
|---|---|:---:|
|
|
| [folders](outputs.tf#L15) | Folders id. | |
|
|
| [folders_sink_writer_identities](outputs.tf#L23) | Folders id. | |
|
|
|
|
<!-- END TFDOC -->
|