|
|
|
|
@@ -42,10 +42,7 @@ module "org" {
|
|
|
|
|
iam = {
|
|
|
|
|
"roles/resourcemanager.projectCreator" = ["group:cloud-admins@example.org"]
|
|
|
|
|
}
|
|
|
|
|
iam_additive_members = {
|
|
|
|
|
"user:compute@example.org" = ["roles/compute.admin", "roles/container.viewer"]
|
|
|
|
|
}
|
|
|
|
|
iam_members = {
|
|
|
|
|
iam_bindings_additive = {
|
|
|
|
|
am1-storage-admin = {
|
|
|
|
|
member = "user:am1@example.org"
|
|
|
|
|
role = "roles/storage.admin"
|
|
|
|
|
@@ -121,20 +118,20 @@ module "org" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# tftest modules=1 resources=17 inventory=basic.yaml
|
|
|
|
|
# tftest modules=1 resources=15 inventory=basic.yaml
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## IAM
|
|
|
|
|
|
|
|
|
|
There are three mutually exclusive ways at the role level of managing IAM in this module
|
|
|
|
|
IAM is managed via several variables that implement different features and levels of control:
|
|
|
|
|
|
|
|
|
|
- non-authoritative via the `iam_additive`, `iam_additive_members` and `iam_members` variables, where bindings created outside this module will coexist with those managed here
|
|
|
|
|
- authoritative via the `group_iam` and `iam` variables, where bindings created outside this module (eg in the console) will be removed at each `terraform apply` cycle if the same role is also managed here
|
|
|
|
|
- authoritative policy via the `iam_policy` variable, where any binding created outside this module (eg in the console) will be removed at each `terraform apply` cycle regardless of the role
|
|
|
|
|
- `iam` and `group_iam` configure authoritative bindings that manage individual roles exclusively, and are internally merged
|
|
|
|
|
- `iam_bindings` configure authoritative bindings with optional support for conditions, and are not internally merged with the previous two variables
|
|
|
|
|
- `iam_bindings_additive` configure additive bindings via individual role/member pairs with optional support conditions
|
|
|
|
|
|
|
|
|
|
The authoritative and additive approaches can be used together, provided different roles are managed by each. The IAM policy is incompatible with the other approaches, and must be used with extreme care.
|
|
|
|
|
The authoritative and additive approaches can be used together, provided different roles are managed by each. Some care must also be taken with the `groups_iam` variable to ensure that variable keys are static values, so that Terraform is able to compute the dependency graph.
|
|
|
|
|
|
|
|
|
|
Some care must also be taken with the `group_iam` variable (and in some situations with the additive variables) to ensure that variable keys are static values, so that Terraform is able to compute the dependency graph.
|
|
|
|
|
Refer to the [project module](../project/README.md#iam) for examples of the IAM interface.
|
|
|
|
|
|
|
|
|
|
## Organization Policies
|
|
|
|
|
|
|
|
|
|
@@ -327,9 +324,7 @@ module "org" {
|
|
|
|
|
|
|
|
|
|
## Data Access Logs
|
|
|
|
|
|
|
|
|
|
Activation of data access logs can be controlled via the `logging_data_access` variable. If the `iam_bindings_authoritative` variable is used to set a resource-level IAM policy, the data access log configuration will also be authoritative as part of the policy.
|
|
|
|
|
|
|
|
|
|
This example shows how to set a non-authoritative access log configuration:
|
|
|
|
|
Activation of data access logs can be controlled via the `logging_data_access` variable.
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
module "org" {
|
|
|
|
|
@@ -349,31 +344,6 @@ module "org" {
|
|
|
|
|
# tftest modules=1 resources=2 inventory=logging-data-access.yaml
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
While this sets an authoritative policies that has exclusive control of both IAM bindings for all roles and data access log configuration, and should be used with extreme care:
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
module "org" {
|
|
|
|
|
source = "./fabric/modules/organization"
|
|
|
|
|
organization_id = var.organization_id
|
|
|
|
|
iam_policy = {
|
|
|
|
|
"roles/owner" = ["group:org-admins@example.com"]
|
|
|
|
|
"roles/resourcemanager.folderAdmin" = ["group:org-admins@example.com"]
|
|
|
|
|
"roles/resourcemanager.organizationAdmin" = ["group:org-admins@example.com"]
|
|
|
|
|
"roles/resourcemanager.projectCreator" = ["group:org-admins@example.com"]
|
|
|
|
|
}
|
|
|
|
|
logging_data_access = {
|
|
|
|
|
allServices = {
|
|
|
|
|
ADMIN_READ = ["group:organization-admins@example.org"]
|
|
|
|
|
}
|
|
|
|
|
"storage.googleapis.com" = {
|
|
|
|
|
DATA_READ = []
|
|
|
|
|
DATA_WRITE = []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# tftest modules=1 resources=1 inventory=iam-policy.yaml
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Custom Roles
|
|
|
|
|
|
|
|
|
|
Custom roles can be defined via the `custom_roles` variable, and referenced via the `custom_role_id` output:
|
|
|
|
|
@@ -461,7 +431,7 @@ module "org" {
|
|
|
|
|
|
|
|
|
|
| name | description | resources |
|
|
|
|
|
|---|---|---|
|
|
|
|
|
| [iam.tf](./iam.tf) | IAM bindings, roles and audit logging resources. | <code>google_organization_iam_binding</code> · <code>google_organization_iam_custom_role</code> · <code>google_organization_iam_member</code> · <code>google_organization_iam_policy</code> |
|
|
|
|
|
| [iam.tf](./iam.tf) | IAM bindings, roles and audit logging resources. | <code>google_organization_iam_binding</code> · <code>google_organization_iam_custom_role</code> · <code>google_organization_iam_member</code> |
|
|
|
|
|
| [logging.tf](./logging.tf) | Log sinks and data access logs. | <code>google_bigquery_dataset_iam_member</code> · <code>google_logging_organization_exclusion</code> · <code>google_logging_organization_sink</code> · <code>google_organization_iam_audit_config</code> · <code>google_project_iam_member</code> · <code>google_pubsub_topic_iam_member</code> · <code>google_storage_bucket_iam_member</code> |
|
|
|
|
|
| [main.tf](./main.tf) | Module-level locals and resources. | <code>google_compute_firewall_policy_association</code> · <code>google_essential_contacts_contact</code> |
|
|
|
|
|
| [org-policy-custom-constraints.tf](./org-policy-custom-constraints.tf) | None | <code>google_org_policy_custom_constraint</code> |
|
|
|
|
|
@@ -475,26 +445,24 @@ module "org" {
|
|
|
|
|
|
|
|
|
|
| name | description | type | required | default |
|
|
|
|
|
|---|---|:---:|:---:|:---:|
|
|
|
|
|
| [organization_id](variables.tf#L214) | Organization id in organizations/nnnnnn format. | <code>string</code> | ✓ | |
|
|
|
|
|
| [organization_id](variables.tf#L208) | Organization id in organizations/nnnnnn format. | <code>string</code> | ✓ | |
|
|
|
|
|
| [contacts](variables.tf#L17) | List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [custom_roles](variables.tf#L24) | Map of role name => list of permissions to create in this project. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [firewall_policy_associations](variables.tf#L31) | Hierarchical firewall policies to associate to this folder, in association name => policy id format. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [group_iam](variables.tf#L38) | Authoritative IAM binding for organization groups, in {GROUP_EMAIL => [ROLES]} format. Group emails need to be static. Can be used in combination with the `iam` variable. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam](variables.tf#L45) | IAM bindings, in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam_additive](variables.tf#L52) | Non authoritative IAM bindings, in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam_additive_members](variables.tf#L59) | IAM additive bindings in {MEMBERS => [ROLE]} format. This might break if members are dynamic values. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam_members](variables.tf#L66) | Individual additive IAM bindings, use this when iam_additive does not work due to dynamic resources. Keys are arbitrary and only used for the internal loop. | <code title="map(object({ member = string role = string condition = optional(object({ expression = string title = string description = optional(string) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam_policy](variables.tf#L81) | IAM authoritative policy in {ROLE => [MEMBERS]} format. Roles and members not explicitly listed will be cleared, use with extreme caution. | <code>map(list(string))</code> | | <code>null</code> |
|
|
|
|
|
| [logging_data_access](variables.tf#L87) | Control activation of data access logs. Format is service => { log type => [exempted members]}. The special 'allServices' key denotes configuration for all services. | <code>map(map(list(string)))</code> | | <code>{}</code> |
|
|
|
|
|
| [logging_exclusions](variables.tf#L102) | Logging exclusions for this organization in the form {NAME -> FILTER}. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [logging_sinks](variables.tf#L109) | Logging sinks to create for the organization. | <code title="map(object({ bq_partitioned_table = optional(bool) description = optional(string) destination = string disabled = optional(bool, false) exclusions = optional(map(string), {}) filter = string include_children = optional(bool, true) type = string }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [network_tags](variables.tf#L139) | Network tags by key name. If `id` is provided, key creation is skipped. The `iam` attribute behaves like the similarly named one at module level. | <code title="map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) id = optional(string) network = string # project_id/vpc_name values = optional(map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) })), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [org_policies](variables.tf#L161) | Organization policies applied to this organization keyed by policy name. | <code title="map(object({ inherit_from_parent = optional(bool) # for list policies only. reset = optional(bool) rules = optional(list(object({ allow = optional(object({ all = optional(bool) values = optional(list(string)) })) deny = optional(object({ all = optional(bool) values = optional(list(string)) })) enforce = optional(bool) # for boolean policies only. condition = optional(object({ description = optional(string) expression = optional(string) location = optional(string) title = optional(string) }), {}) })), []) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [org_policies_data_path](variables.tf#L188) | Path containing org policies in YAML format. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [org_policy_custom_constraints](variables.tf#L194) | Organization policy custom constraints keyed by constraint name. | <code title="map(object({ display_name = optional(string) description = optional(string) action_type = string condition = string method_types = list(string) resource_types = list(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [org_policy_custom_constraints_data_path](variables.tf#L208) | Path containing org policy custom constraints in YAML format. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [tag_bindings](variables.tf#L223) | Tag bindings for this organization, in key => tag value id format. | <code>map(string)</code> | | <code>null</code> |
|
|
|
|
|
| [tags](variables.tf#L229) | Tags by key name. If `id` is provided, key or value creation is skipped. The `iam` attribute behaves like the similarly named one at module level. | <code title="map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) id = optional(string) values = optional(map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) id = optional(string) })), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam_bindings](variables.tf#L52) | Authoritative IAM bindings in {ROLE => {members = [], condition = {}}}. | <code title="map(object({ members = list(string) condition = optional(object({ expression = string title = string description = optional(string) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [iam_bindings_additive](variables.tf#L66) | Individual additive IAM bindings. Keys are arbitrary. | <code title="map(object({ member = string role = string condition = optional(object({ expression = string title = string description = optional(string) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [logging_data_access](variables.tf#L81) | Control activation of data access logs. Format is service => { log type => [exempted members]}. The special 'allServices' key denotes configuration for all services. | <code>map(map(list(string)))</code> | | <code>{}</code> |
|
|
|
|
|
| [logging_exclusions](variables.tf#L96) | Logging exclusions for this organization in the form {NAME -> FILTER}. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [logging_sinks](variables.tf#L103) | Logging sinks to create for the organization. | <code title="map(object({ bq_partitioned_table = optional(bool) description = optional(string) destination = string disabled = optional(bool, false) exclusions = optional(map(string), {}) filter = string include_children = optional(bool, true) type = string }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [network_tags](variables.tf#L133) | Network tags by key name. If `id` is provided, key creation is skipped. The `iam` attribute behaves like the similarly named one at module level. | <code title="map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) id = optional(string) network = string # project_id/vpc_name values = optional(map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) })), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [org_policies](variables.tf#L155) | Organization policies applied to this organization keyed by policy name. | <code title="map(object({ inherit_from_parent = optional(bool) # for list policies only. reset = optional(bool) rules = optional(list(object({ allow = optional(object({ all = optional(bool) values = optional(list(string)) })) deny = optional(object({ all = optional(bool) values = optional(list(string)) })) enforce = optional(bool) # for boolean policies only. condition = optional(object({ description = optional(string) expression = optional(string) location = optional(string) title = optional(string) }), {}) })), []) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [org_policies_data_path](variables.tf#L182) | Path containing org policies in YAML format. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [org_policy_custom_constraints](variables.tf#L188) | Organization policy custom constraints keyed by constraint name. | <code title="map(object({ display_name = optional(string) description = optional(string) action_type = string condition = string method_types = list(string) resource_types = list(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [org_policy_custom_constraints_data_path](variables.tf#L202) | Path containing org policy custom constraints in YAML format. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [tag_bindings](variables.tf#L217) | Tag bindings for this organization, in key => tag value id format. | <code>map(string)</code> | | <code>null</code> |
|
|
|
|
|
| [tags](variables.tf#L223) | Tags by key name. If `id` is provided, key or value creation is skipped. The `iam` attribute behaves like the similarly named one at module level. | <code title="map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) id = optional(string) values = optional(map(object({ description = optional(string, "Managed by the Terraform organization module.") iam = optional(map(list(string)), {}) id = optional(string) })), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
|
|
|
|
|
## Outputs
|
|
|
|
|
|
|
|
|
|
|