Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify the scope of Cosmos DB connection strings in Terraform output #9621

Closed
Sarah-Aly opened this issue Dec 2, 2020 · 7 comments · Fixed by #25510
Closed

Specify the scope of Cosmos DB connection strings in Terraform output #9621

Sarah-Aly opened this issue Dec 2, 2020 · 7 comments · Fixed by #25510

Comments

@Sarah-Aly
Copy link

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

@tombuildsstuff
Copy link
Member

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 tombuildsstuff added this to the v3.0.0 milestone Dec 2, 2020
@favoretti
Copy link
Collaborator

@tombuildsstuff how do you wanna break them up, based on description? Wouldn't that be a bit too flaky?

@tombuildsstuff
Copy link
Member

@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?

@favoretti
Copy link
Collaborator

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?

@tombuildsstuff
Copy link
Member

@favoretti sorry missed this ping - agreed it's possible there's multiple combinations available here, but I think we could likely add those as folks need them, others could make sense on the other resources too (e.g. on cosmosdb_table as in #9990), WDYT?

@katbyte katbyte modified the milestones: v3.0.0-to-review, v3.0.0 Oct 18, 2021
@katbyte katbyte modified the milestones: v3.0.0, v4.0.0 Mar 23, 2022
@VRabadan
Copy link

Just came across this. I think that at least primary_connection_string would be useful to use in other parts of the terraform file. Current list of values is confusing to use.

Copy link

github-actions bot commented May 9, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants