clean(infra/dcp): remove obsolete dcp environment variables and redundant embeddings flags - #194
clean(infra/dcp): remove obsolete dcp environment variables and redundant embeddings flags#194clincoln8 wants to merge 1 commit into
Conversation
…dant embeddings flags
| value = var.redis_port | ||
| } | ||
| env { | ||
| name = "ENABLE_UNIQUE_INGESTION_RUNS" |
There was a problem hiding this comment.
Code Review
This pull request cleans up configuration variables by removing resolve_with_spanner_embeddings and other temporary environment variables across the Terraform infrastructure and integration tests. The review feedback suggests adhering to the principle of least privilege by conditionally granting the roles/aiplatform.user IAM role only when both Spanner and embeddings generation are enabled. To achieve this, the reviewer recommends adding and passing the enable_embeddings_generation variable through the nested Terraform modules.
| ], | ||
| var.use_spanner ? ["roles/spanner.databaseUser"] : [], | ||
| var.use_spanner && var.resolve_with_spanner_embeddings ? ["roles/aiplatform.user"] : [] | ||
| var.use_spanner ? ["roles/aiplatform.user"] : [] |
There was a problem hiding this comment.
To adhere to the principle of least privilege, the roles/aiplatform.user role should only be granted if both Spanner and embeddings generation are enabled. Granting it unconditionally when use_spanner is true could lead to excessive permissions if embeddings generation is disabled.
var.use_spanner && var.enable_embeddings_generation ? ["roles/aiplatform.user"] : []
| variable "resolve_with_spanner_embeddings" { | ||
| type = bool | ||
| } | ||
|
|
There was a problem hiding this comment.
| ]) | ||
| secret_env_vars = local.datacommons_services_secrets | ||
| resolve_with_spanner_embeddings = var.datacommons_services_config.resolve_with_spanner_embeddings | ||
| website_search_scope = var.datacommons_services_config.website_search_scope |
There was a problem hiding this comment.
Pass the enable_embeddings_generation variable from the stack configuration to the datacommons_services module. To ensure the default value defined in the innermost module is respected, make sure this attribute is declared as optional in the intermediate configuration object (spanner_config) and defaults to null.
enable_embeddings_generation = var.spanner_config.enable_embeddings_generation
website_search_scope = var.datacommons_services_config.website_search_scope
References
- When designing nested Terraform modules, set the top-level variable default to null and declare the attribute as optional in intermediate module configuration objects. This ensures that the default value defined in the innermost module is respected and not overridden by parent defaults.
Overview
Removes obsolete environment variables and redundant Terraform variables across DCP infrastructure (
infra/dcp) and integration test configurations, aligning with recentcdc_servicescleanup indatcom-website.Changes
RESOLVE_WITH_SPANNER_EMBEDDINGS,ENABLE_UNIQUE_HISTORY_RECORDS, andUSE_SPANNER_KEY_VALUE_STOREfrom the Cloud Run container definition. Simplified IAM role condition forroles/aiplatform.usertovar.use_spanner.ENABLE_UNIQUE_INGESTION_RUNS.resolve_with_spanner_embeddings/datacommons_services_resolve_with_spanner_embeddingsvariable definitions and pass-throughs. Alignedingestion_preprocessing_jobto passenable_spanner_embeddings = var.spanner_config.enable_embeddings_generation.- RESOLVE_WITH_SPANNER_EMBEDDINGS=trueoverride fromdocker-compose.test.ymland updated documentation/comments incustom_feature_flags.yamlandREADME.md.Verification
uv run pytest packages/datacommons-admin/tests/test_admin_cli.py.terraform validate.