Terraform-provider-azurerm: Specify the scope of Cosmos DB connection strings in Terraform output

Created on 2 Dec 2020  路  4Comments  路  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

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

New or Affected Resource(s)

  • azurerm_cosmosdb_account

References

bug serviccosmosdb

Most helpful comment

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_string
  • secondary_connection_string
  • primary_readonly_connection_string
  • secondary_readonly_connection_string

All 4 comments

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_string
  • secondary_connection_string
  • primary_readonly_connection_string
  • secondary_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?

Was this page helpful?
0 / 5 - 0 ratings