-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
93 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,26 +21,26 @@ This module allows the creation and management of folders, including support for | |
```hcl | ||
module "folder" { | ||
source = "./fabric/modules/folder" | ||
parent = "organizations/1234567890" | ||
parent = var.folder_id | ||
name = "Folder name" | ||
group_iam = { | ||
"[email protected]" = [ | ||
"${var.group_email}" = [ | ||
"roles/owner", | ||
"roles/resourcemanager.folderAdmin", | ||
"roles/resourcemanager.projectCreator" | ||
] | ||
} | ||
iam = { | ||
"roles/owner" = ["user:[email protected]"] | ||
"roles/owner" = ["serviceAccount:${var.service_account.email}"] | ||
} | ||
iam_bindings_additive = { | ||
am1-storage-admin = { | ||
member = "user:[email protected]" | ||
member = "serviceAccount:${var.service_account.email}" | ||
role = "roles/storage.admin" | ||
} | ||
} | ||
} | ||
# tftest modules=1 resources=5 inventory=iam.yaml | ||
# tftest modules=1 resources=5 inventory=iam.yaml e2e | ||
``` | ||
|
||
## IAM | ||
|
@@ -62,7 +62,7 @@ To manage organization policies, the `orgpolicy.googleapis.com` service should b | |
```hcl | ||
module "folder" { | ||
source = "./fabric/modules/folder" | ||
parent = "organizations/1234567890" | ||
parent = var.folder_id | ||
name = "Folder name" | ||
org_policies = { | ||
"compute.disableGuestAttributesAccess" = { | ||
|
@@ -109,12 +109,67 @@ module "folder" { | |
} | ||
} | ||
} | ||
# tftest modules=1 resources=8 inventory=org-policies.yaml | ||
# tftest modules=1 resources=8 inventory=org-policies.yaml e2e | ||
``` | ||
|
||
### Organization Policy Factory | ||
|
||
See the [organization policy factory in the project module](../project#organization-policy-factory). | ||
Organization policies can be loaded from a directory containing YAML files where each file defines one or more constraints. The structure of the YAML files is exactly the same as the org_policies variable. | ||
|
||
Note that constraints defined via org_policies take precedence over those in org_policies_data_path. In other words, if you specify the same constraint in a YAML file and in the org_policies variable, the latter will take priority. | ||
|
||
The example below deploys a few organization policies split between two YAML files. | ||
|
||
```hcl | ||
module "folder" { | ||
source = "./fabric/modules/folder" | ||
parent = var.folder_id | ||
name = "Folder name" | ||
org_policies_data_path = "configs/org-policies/" | ||
} | ||
# tftest modules=1 resources=8 files=boolean,list inventory=org-policies.yaml e2e | ||
``` | ||
|
||
```yaml | ||
# tftest-file id=boolean path=configs/org-policies/boolean.yaml | ||
compute.disableGuestAttributesAccess: | ||
rules: | ||
- enforce: true | ||
compute.skipDefaultNetworkCreation: | ||
rules: | ||
- enforce: true | ||
iam.disableServiceAccountKeyCreation: | ||
rules: | ||
- enforce: true | ||
iam.disableServiceAccountKeyUpload: | ||
rules: | ||
- condition: | ||
description: test condition | ||
expression: resource.matchTagId('tagKeys/1234', 'tagValues/1234') | ||
location: somewhere | ||
title: condition | ||
enforce: true | ||
- enforce: false | ||
``` | ||
```yaml | ||
# tftest-file id=list path=configs/org-policies/list.yaml | ||
compute.trustedImageProjects: | ||
rules: | ||
- allow: | ||
values: | ||
- projects/my-project | ||
compute.vmExternalIpAccess: | ||
rules: | ||
- deny: | ||
all: true | ||
iam.allowedPolicyMemberDomains: | ||
rules: | ||
- allow: | ||
values: | ||
- C0xxxxxxx | ||
- C0yyyyyyy | ||
``` | ||
## Hierarchical Firewall Policy Attachments | ||
|
@@ -133,50 +188,49 @@ module "firewall-policy" { | |
module "folder" { | ||
source = "./fabric/modules/folder" | ||
parent = "organizations/1234567890" | ||
parent = var.folder_id | ||
name = "Folder name" | ||
# attachment via the organization module | ||
firewall_policy = { | ||
name = "test-1" | ||
policy = module.firewall-policy.id | ||
} | ||
} | ||
# tftest modules=2 resources=3 | ||
# tftest modules=2 resources=3 e2e | ||
``` | ||
|
||
## Log Sinks | ||
|
||
```hcl | ||
module "gcs" { | ||
source = "./fabric/modules/gcs" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
name = "gcs_sink" | ||
force_destroy = true | ||
} | ||
module "dataset" { | ||
source = "./fabric/modules/bigquery-dataset" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
id = "bq_sink" | ||
} | ||
module "pubsub" { | ||
source = "./fabric/modules/pubsub" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
name = "pubsub_sink" | ||
} | ||
module "bucket" { | ||
source = "./fabric/modules/logging-bucket" | ||
parent_type = "project" | ||
parent = "my-project" | ||
parent = var.project_id | ||
id = "bucket" | ||
} | ||
module "folder-sink" { | ||
source = "./fabric/modules/folder" | ||
parent = "folders/657104291943" | ||
name = "my-folder" | ||
name = "Folder name" | ||
parent = var.folder_id | ||
logging_sinks = { | ||
warnings = { | ||
destination = module.gcs.id | ||
|
@@ -206,7 +260,7 @@ module "folder-sink" { | |
no-gce-instances = "resource.type=gce_instance" | ||
} | ||
} | ||
# tftest modules=5 resources=14 inventory=logging.yaml | ||
# tftest modules=5 resources=14 inventory=logging.yaml e2e | ||
``` | ||
|
||
## Data Access Logs | ||
|
@@ -218,20 +272,20 @@ This example shows how to set a non-authoritative access log configuration: | |
```hcl | ||
module "folder" { | ||
source = "./fabric/modules/folder" | ||
parent = "folders/657104291943" | ||
name = "my-folder" | ||
parent = var.folder_id | ||
name = "Folder name" | ||
logging_data_access = { | ||
allServices = { | ||
# logs for principals listed here will be excluded | ||
ADMIN_READ = ["group:[email protected]"] | ||
ADMIN_READ = ["group:${var.group_email}"] | ||
} | ||
"storage.googleapis.com" = { | ||
DATA_READ = [] | ||
DATA_WRITE = [] | ||
} | ||
} | ||
} | ||
# tftest modules=1 resources=3 inventory=logging-data-access.yaml | ||
# tftest modules=1 resources=3 inventory=logging-data-access.yaml e2e | ||
``` | ||
|
||
## Tags | ||
|
@@ -256,14 +310,13 @@ module "org" { | |
module "folder" { | ||
source = "./fabric/modules/folder" | ||
name = "Test" | ||
parent = module.org.organization_id | ||
name = "Folder name" | ||
parent = var.folder_id | ||
tag_bindings = { | ||
env-prod = module.org.tag_values["environment/prod"].id | ||
foo = "tagValues/12345678" | ||
} | ||
} | ||
# tftest modules=2 resources=6 inventory=tags.yaml | ||
# tftest modules=2 resources=5 inventory=tags.yaml e2e | ||
``` | ||
|
||
<!-- TFDOC OPTS files:1 --> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,27 +15,27 @@ | |
values: | ||
module.folder.google_folder.folder[0]: | ||
display_name: Folder name | ||
parent: organizations/1234567890 | ||
parent: folders/1122334455 | ||
timeouts: null | ||
module.folder.google_folder_iam_binding.authoritative["roles/owner"]: | ||
condition: [] | ||
members: | ||
- group:cloud-owners@example.org | ||
- user:[email protected] | ||
- group:organization-admins@example.org | ||
- serviceAccount:service_account_email | ||
role: roles/owner | ||
module.folder.google_folder_iam_binding.authoritative["roles/resourcemanager.folderAdmin"]: | ||
condition: [] | ||
members: | ||
- group:cloud-owners@example.org | ||
- group:organization-admins@example.org | ||
role: roles/resourcemanager.folderAdmin | ||
module.folder.google_folder_iam_binding.authoritative["roles/resourcemanager.projectCreator"]: | ||
condition: [] | ||
members: | ||
- group:cloud-owners@example.org | ||
- group:organization-admins@example.org | ||
role: roles/resourcemanager.projectCreator | ||
module.folder.google_folder_iam_member.bindings["am1-storage-admin"]: | ||
condition: [] | ||
member: user:[email protected] | ||
member: serviceAccount:service_account_email | ||
role: roles/storage.admin | ||
|
||
counts: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters