Scope of Cosmos DB connection strings needs to be specified in Terraform output to reflect the same level of details that Azure CLI provides.
Currently Terraform spits an array of connection strings that looks like below:
{
"name": "CosmosDB_Connection_String",
"slotSetting": false,
"value": [
"AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>"
]
}
Output example when using az cosmosdb keys list --type connection-strings
{
"connectionStrings": [
{
"connectionString": "AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"description": "Primary SQL Connection String"
},
{
"connectionString": "AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"description": "Secondary SQL Connection String"
},
{
"connectionString": "AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"description": "Primary Read-Only SQL Connection String"
},
{
"connectionString": "AccountEndpoint=https://<redacted>.documents.azure.com:443/;AccountKey=<redacted>",
"description": "Secondary Read-Only SQL Connection String"
}
]
}
Taking a look through here it appears the connection_strings block should be deprecated and replaced by two top-level properties to match the others: e.g.:
primary_connection_stringsecondary_connection_stringprimary_readonly_connection_stringsecondary_readonly_connection_string@tombuildsstuff how do you wanna break them up, based on description? Wouldn't that be a bit too flaky?
@favoretti I don't see another option unfortunately, we'll have to do this conditionally like so:
primaryReadOnlyConnectionString := ""
if v, ok := connectionStrings["Primary Read-Only SQL Connection String"]; ok {
primaryReadOnlyConnectionString = v.(string)
}
which should avoid any breaking changes to this on the Azure side, by setting an empty string by default - WDYT?
Yeah, that's the only way I saw as well, unfortunately, but now I'm kinda wondering how many combinations would there be, since that one has "SQL" in it. Mongo would have its own set, gremlin its own, etc, etc?
Most helpful comment
Taking a look through here it appears the
connection_stringsblock should be deprecated and replaced by two top-level properties to match the others: e.g.:primary_connection_stringsecondary_connection_stringprimary_readonly_connection_stringsecondary_readonly_connection_string