Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.6 KB

File metadata and controls

44 lines (32 loc) · 1.6 KB
page_title resolve_datacenter function - terraform-provider-astra
subcategory
description

function: resolve_datacenter

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.

Example Usage

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]}"]
}

Signature

resolve_datacenter(database object, region string...) string

Arguments

  1. database (Object) The database object to resolve the datacenter from. This should be the result of an "astra_database" resource or data source.
  1. 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.