'Output CosmosDB String
I'm trying to call out Connection Strings from the CosmosDB in to KeyVault Secret. I keep getting this error but am unsure what the fix is.
There is nothing online what suggests on how to call out the CosmosDB
The output code is
output "connection_strings" {
value = azurerm_cosmosdb_account.cosmos_db.connection_strings
}
and on key vault resource is setout as this
resource "azurerm_key_vault_secret" "test" {
name = "Tst"
value = module.cosmosDB.connection_strings
key_vault_id = module.kv-secrets.id
}
The error that I get in the CLI is module.cosmosDB.connection_strings is list of string with 4 elements
Solution 1:[1]
As per Terraform doc connection strings is a list:
connection_strings - A list of connection strings available for this CosmosDB account
If you want to store the connection string into a secret, you should refer to it as:
module.cosmosDB.connection_strings[0]
Solution 2:[2]
If this hasnt be resolved yet, the way we access the connection_string for cosmos
azurerm_cosmosdb_account.cosmos_db.connection_strings.0
As you are exposing the connection_strings completely show be able to access it by adding .0 to the end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jaime S |
| Solution 2 | Miguel Laranjeira |
