Add support for dynamic tags (#3897)
* Allow creation of dynamic tags * Extend project factory and related modules to support dynamic values * Extend folder and organization modules * project and organization readme * Simplify dynamic tag support and remove unnecessary restrictions • Schemas & Validations: Removed the restriction that forbade combining IAM fields with allowed_values_regex on tags. Updated validations in project and organization modules, and simplified all relevant JSON schemas. • Module Tag Bindings: Simplified the tag_value assignment in folder , project , gcs , bigquery-dataset , and kms modules by removing the defensive can(regex(...)) check and calling templatestring directly. • Outputs: Removed the tags_dynamic output from project and organization modules, as the same information is now available in tag_keys . • Project Factory: Updated tag_vars_projects in projects.tf to use the native namespaced_name attribute and filtered manually for dynamic tags. * fix(organization, project): fix linting and tests for dynamic tag support - Align allowed_values_regex and description extraction in _tags_merged locals to use lookup() for consistency with other fields. - Fix spacing in project context variable (alphabetical ordering). - Update organization tags test to include the new cost_center tag key with allowed_values_regex. - Update project tags test to include the new cost_center tag key and reflect the resolved allowed_values_regex on environment. * refactor(gcs): refine tag bindings and fix context test - Add _tag_bindings local to pre-resolve context references, enabling templatestring to receive a direct map reference (required by Terraform). - Use var.context.tag_vars instead of the non-existent local.ctx.tag_vars. - Fix HCL syntax in context.tfvars (escaped inner quotes). - Update context test inventory to reflect 3 tag bindings including a dynamic value resolved via templatestring. * refactor: align modules with tag binding context pattern - Add _tag_bindings local + templatestring dance to cloud-run-v2, compute-vm, folder, kms modules (bigquery-dataset already had it) - Exclude tag_vars from local.ctx in cloud-run-v2, compute-vm, folder, kms, project modules (bigquery-dataset already had it) - Add tag_vars to context variable in cloud-run-v2, compute-vm modules (others already had it) - Update all context tests with dynamic tag binding values using var.context.tag_vars * docs: add module-level tftest.yaml test instructions to GEMINI.md * docs: regenerate READMEs after tag-regex alignment - Regenerate variable tables in 7 module READMEs to reflect line number shifts from prior tag-regex changes - Add tag_vars exclusion to gcs ctx local - Fix whitespace alignment in iam-service-account and project-factory tag_vars blocks - Update tftest resource counts for organization and project - Remove tags_dynamic from organization/project output tables * fix(project-factory): update test inventory for tag_bindings module split - Move tag binding address from folder-2 to folder-2-iam in test inventory (tag_bindings moved from creation to IAM modules) - Update module instance count from 34 to 35 - Regenerate README tables after terraform fmt line shifts - Apply terraform fmt to variables.tf * refactor(project-factory): remove unnecessary depends_on from folder-iam modules Folder IAM modules depend on their own folder creation modules, not on module.projects. The explicit depends_on was leftover from an earlier design. * FAST stages * Address review comments. - FAST Stages: - Added tag_keys to output-files.tf in 0-org-setup to pass org tags via tfvars. - Sorted tag_keys and tag_values in output-files.tf. - Updated project-factory, networking, and security stages to use tag_keys. - Filtered tag_keys for dynamic tags only. - Modules: - Excluded tag_vars from local.ctx in iam-service-account and organization. - Simplified tag_value in iam-service-account. - Tests: - Updated test inventories for 0-org-setup and project-factory. * Fix tf format * Fix tfdoc * docs: add ADR for templatestring vars convention and update status of base path ADR * More tfdoc * Update schemas * Use endswith in context loop * Address review * Update FAST readmes * Update last modules * Terraform fmt * Revert alloydb * Fix whitespace --------- Co-authored-by: Ludovico Magnocavallo <ludo@qix.it>
This commit is contained in:
@@ -1213,45 +1213,45 @@ module "sole-tenancy" {
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [name](variables.tf#L354) | Instance name. | <code>string</code> | ✓ | |
|
||||
| [network_interfaces](variables.tf#L366) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | <code>list(object({…}))</code> | ✓ | |
|
||||
| [project_id](variables.tf#L406) | Project id. | <code>string</code> | ✓ | |
|
||||
| [zone](variables.tf#L563) | Compute zone. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L358) | Instance name. | <code>string</code> | ✓ | |
|
||||
| [network_interfaces](variables.tf#L370) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | <code>list(object({…}))</code> | ✓ | |
|
||||
| [project_id](variables.tf#L410) | Project id. | <code>string</code> | ✓ | |
|
||||
| [zone](variables.tf#L567) | Compute zone. | <code>string</code> | ✓ | |
|
||||
| [attached_disks](variables.tf#L17) | Additional disks. Source type is one of 'image' (zonal disks in vms and template), 'snapshot' (vm), 'existing', and null. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [boot_disk](variables.tf#L57) | Boot disk properties. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [can_ip_forward](variables.tf#L114) | Enable IP forwarding. | <code>bool</code> | | <code>false</code> |
|
||||
| [confidential_compute](variables.tf#L120) | Confidential Compute configuration. Set to 'SEV' or 'SEV_SNP' to enable. | <code>string</code> | | <code>null</code> |
|
||||
| [context](variables.tf#L130) | Context-specific interpolations. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [create_template](variables.tf#L147) | Create instance template instead of instances. Defaults to a global template. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [description](variables.tf#L156) | Description of a Compute Instance. | <code>string</code> | | <code>"Managed by the compute-vm Terraform module."</code> |
|
||||
| [enable_display](variables.tf#L162) | Enable virtual display on the instances. | <code>bool</code> | | <code>false</code> |
|
||||
| [encryption](variables.tf#L168) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [gpu](variables.tf#L179) | GPU information. Based on https://cloud.google.com/compute/docs/gpus. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [group](variables.tf#L214) | Instance group configuration. Set 'named_ports' to create a new unmanaged instance group, or provide an existing group self_link/id in 'membership' to join one. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [hostname](variables.tf#L223) | Instance FQDN name. | <code>string</code> | | <code>null</code> |
|
||||
| [iam](variables.tf#L229) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
||||
| [instance_schedule](variables.tf#L235) | Assign or create and assign an instance schedule policy. Set active to null to detach a policy from vm before destroying. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [kms_autokeys](variables.tf#L259) | KMS Autokey key handles. If location is not specified it will be inferred from the zone. Key handle names will be added to the kms_keys context with an `autokeys/` prefix. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [labels](variables.tf#L277) | Instance labels. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [lifecycle_config](variables.tf#L283) | Instance lifecycle and operational configurations. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [machine_features_config](variables.tf#L305) | Machine-level configuration. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [machine_type](variables.tf#L329) | Machine type. | <code>string</code> | | <code>"e2-micro"</code> |
|
||||
| [metadata](variables.tf#L335) | Instance metadata. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [metadata_startup_script](variables.tf#L341) | Instance startup script. Will trigger recreation on change, even after importing. | <code>string</code> | | <code>null</code> |
|
||||
| [min_cpu_platform](variables.tf#L348) | Minimum CPU platform. | <code>string</code> | | <code>null</code> |
|
||||
| [network_attached_interfaces](variables.tf#L359) | Network interfaces using network attachments. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [network_performance_tier](variables.tf#L389) | Network performance total egress bandwidth tier. | <code>string</code> | | <code>null</code> |
|
||||
| [network_tag_bindings](variables.tf#L399) | Resource manager tag bindings in arbitrary key => tag key or value id format. Set on both the instance only for networking purposes, and modifiable without impacting the main resource lifecycle. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [project_number](variables.tf#L411) | Project number. Used in tag bindings to avoid a permadiff. | <code>string</code> | | <code>null</code> |
|
||||
| [resource_policies](variables.tf#L417) | Resource policies to attach to the instance or template. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [scheduling_config](variables.tf#L424) | Scheduling configuration for the instance. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [scratch_disks](variables.tf#L459) | Scratch disks configuration. | <code>object({…})</code> | | <code>{…}</code> |
|
||||
| [service_account](variables.tf#L472) | Service account email and scopes. If email is null, the default Compute service account will be used unless auto_create is true, in which case a service account will be created. Set the variable to null to avoid attaching a service account. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [shielded_config](variables.tf#L483) | Shielded VM configuration of the instances. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [snapshot_schedules](variables.tf#L493) | Snapshot schedule resource policies that can be attached to disks. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [tag_bindings](variables.tf#L536) | Resource manager tag bindings in arbitrary key => tag key or value id format. Set on both the instance and zonal disks, and modifiable without impacting the main resource lifecycle. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [tag_bindings_immutable](variables.tf#L543) | Immutable resource manager tag bindings, in tagKeys/id => tagValues/id format. These are set on the instance or instance template at creation time, and trigger recreation if changed. | <code>map(string)</code> | | <code>null</code> |
|
||||
| [tags](variables.tf#L557) | Instance network tags for firewall rule targets. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [create_template](variables.tf#L151) | Create instance template instead of instances. Defaults to a global template. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [description](variables.tf#L160) | Description of a Compute Instance. | <code>string</code> | | <code>"Managed by the compute-vm Terraform module."</code> |
|
||||
| [enable_display](variables.tf#L166) | Enable virtual display on the instances. | <code>bool</code> | | <code>false</code> |
|
||||
| [encryption](variables.tf#L172) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [gpu](variables.tf#L183) | GPU information. Based on https://cloud.google.com/compute/docs/gpus. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [group](variables.tf#L218) | Instance group configuration. Set 'named_ports' to create a new unmanaged instance group, or provide an existing group self_link/id in 'membership' to join one. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [hostname](variables.tf#L227) | Instance FQDN name. | <code>string</code> | | <code>null</code> |
|
||||
| [iam](variables.tf#L233) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
||||
| [instance_schedule](variables.tf#L239) | Assign or create and assign an instance schedule policy. Set active to null to detach a policy from vm before destroying. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [kms_autokeys](variables.tf#L263) | KMS Autokey key handles. If location is not specified it will be inferred from the zone. Key handle names will be added to the kms_keys context with an `autokeys/` prefix. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [labels](variables.tf#L281) | Instance labels. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [lifecycle_config](variables.tf#L287) | Instance lifecycle and operational configurations. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [machine_features_config](variables.tf#L309) | Machine-level configuration. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [machine_type](variables.tf#L333) | Machine type. | <code>string</code> | | <code>"e2-micro"</code> |
|
||||
| [metadata](variables.tf#L339) | Instance metadata. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [metadata_startup_script](variables.tf#L345) | Instance startup script. Will trigger recreation on change, even after importing. | <code>string</code> | | <code>null</code> |
|
||||
| [min_cpu_platform](variables.tf#L352) | Minimum CPU platform. | <code>string</code> | | <code>null</code> |
|
||||
| [network_attached_interfaces](variables.tf#L363) | Network interfaces using network attachments. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [network_performance_tier](variables.tf#L393) | Network performance total egress bandwidth tier. | <code>string</code> | | <code>null</code> |
|
||||
| [network_tag_bindings](variables.tf#L403) | Resource manager tag bindings in arbitrary key => tag key or value id format. Set on both the instance only for networking purposes, and modifiable without impacting the main resource lifecycle. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [project_number](variables.tf#L415) | Project number. Used in tag bindings to avoid a permadiff. | <code>string</code> | | <code>null</code> |
|
||||
| [resource_policies](variables.tf#L421) | Resource policies to attach to the instance or template. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [scheduling_config](variables.tf#L428) | Scheduling configuration for the instance. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [scratch_disks](variables.tf#L463) | Scratch disks configuration. | <code>object({…})</code> | | <code>{…}</code> |
|
||||
| [service_account](variables.tf#L476) | Service account email and scopes. If email is null, the default Compute service account will be used unless auto_create is true, in which case a service account will be created. Set the variable to null to avoid attaching a service account. | <code>object({…})</code> | | <code>{}</code> |
|
||||
| [shielded_config](variables.tf#L487) | Shielded VM configuration of the instances. | <code>object({…})</code> | | <code>null</code> |
|
||||
| [snapshot_schedules](variables.tf#L497) | Snapshot schedule resource policies that can be attached to disks. | <code>map(object({…}))</code> | | <code>{}</code> |
|
||||
| [tag_bindings](variables.tf#L540) | Resource manager tag bindings in arbitrary key => tag key or value id format. Set on both the instance and zonal disks, and modifiable without impacting the main resource lifecycle. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [tag_bindings_immutable](variables.tf#L547) | Immutable resource manager tag bindings, in tagKeys/id => tagValues/id format. These are set on the instance or instance template at creation time, and trigger recreation if changed. | <code>map(string)</code> | | <code>null</code> |
|
||||
| [tags](variables.tf#L561) | Instance network tags for firewall rule targets. | <code>list(string)</code> | | <code>[]</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user