| page_title | resolve_datacenter function - terraform-provider-astra |
|---|---|
| subcategory | |
| description |
Resolves the datacenter ID for a given database and optional region (if the database has multiple regions). Helpful for components that require a datacenter ID such as PCU group associations and private links.
data "astra_database" "example_db" {
# ...
}
locals {
# If the database has multiple regions, you can specify the desired one explicitly
dc_id1 = provider::astra::resolve_datacenter(data.astra_database.example_db, "us-central1")
# Or, if the database has only one region, you can omit the second argument
dc_id2 = provider::astra::resolve_datacenter(data.astra_database.example_db)
# This is all shorthand for the following much longer expression:
dc_id3 = data.astra_database.example_db.datacenters["${data.astra_database.example_db.cloud_provider}.${data.astra_database.example_db.regions[0]}"]
}resolve_datacenter(database object, region string...) string
database(Object) The database object to resolve the datacenter from. This should be the result of an "astra_database" resource or data source.
region(Variadic, String) The region to resolve the datacenter for. If not provided, the function will attempt to resolve the datacenter if there is only one configured.