straight-doctor-88042
11/18/2024, 3:07 PM# Define the list of catalogs and schemas
catalog_schema_list = {
    db_catalogs.db_catalog_source: [
        {"schema_name": "general"}
    ],
    db_catalogs.db_catalog_archive: [
        {"schema_name": "general"}
    ], 
    db_catalogs.db_catalog_model: [
        {"schema_name": "general"}
    ]
}
# Loop through the list and create the schemas dynamically
for catalog, schemas in catalog_schema_list.items():
    for schema_name in schemas:
    # Construct a unique resource name to resolve Output values
        resource_name = pulumi.Output.concat("db_schema_", catalog.name, "_", schema_name["schema_name"],"_")\
            .apply(lambda name: name.replace("_dev", "").replace("_", "-") + constants.config_env_name)
        resource_name.apply(lambda rn: databricks.Schema(
            rn,
            name=schema_name["schema_name"],
            owner=db_usermanagement.service_principal.application_id,
            metastore_id=db_metastore.metastore.id,
            catalog_name=catalog.name,
            opts=pulumi.ResourceOptions(
                provider=db_workspaces.provider_db_workspace_env
                ,parent=catalog
            )
        ))db_schema_source_general = databricks.Schema("db-catalog-source-general-"+ constants.config_env_name
    ,name="general"
    ,owner= db_usermanagement.service_principal.application_id
    ,metastore_id=db_metastore.metastore.id
    ,catalog_name=db_catalogs.db_catalog_source.name
    #,opts=pulumi.ResourceOptions(parent=db_catalog_source)
    ,opts=pulumi.ResourceOptions(provider=db_workspaces.provider_db_workspace_env,parent=db_catalogs.db_catalog_source)
)No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by