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

r/cosmosdb_table: expose connection strings #9990

Open
dzmitry-lahoda opened this issue Dec 23, 2020 · 5 comments
Open

r/cosmosdb_table: expose connection strings #9990

dzmitry-lahoda opened this issue Dec 23, 2020 · 5 comments

Comments

@dzmitry-lahoda
Copy link
Contributor

dzmitry-lahoda commented Dec 23, 2020

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

Terraform (and AzureRM Provider) Version

D:\src> terraform -v
Terraform v0.13.2

Your version of Terraform is out of date! The latest version
is 0.14.3. You can update by downloading from https://www.terraform.io/downloads.html
D:\src>

Affected Resource(s)

Cosmos Db Table API

  • azurerm_cosmosdb_account
  • azurerm_cosmosdb_table

Terraform Configuration Files

same as here https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_table and and azurerm_cosmosdb_account write_endpoints[0]

Debug Output

Links to documents

https://...-westeurope.documents.azure.com:443/;

Expected Behaviour

Links to table

https://....table.cosmos.azure.com:443/;

Actual Behaviour

I get link to document.

Steps to Reproduce

  • follow the steps of official docs for table in cosmos
  • try to obtain connection string to it
  • try to create .net sdk (or any other i believe) client and write

Important Factoids

  • azure portal shows table created
  • azure portal shows correct link and connection string, to created table, not document
@dzmitry-lahoda
Copy link
Contributor Author

locals {
    locations = { germanywestcentral = "germanywestcentral", canadaeast = "canadaeast"}
}

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"      
    }
  }
}
provider "azurerm" {
  features {}
}
resource "azurerm_resource_group" "default" {
  name     = "rglahodatf-canadaeast"
  location = "canadaeast"
}



resource "azurerm_cosmosdb_account" "default" {
  name                      =  "cosmos-lahodatf"
  location                  =  azurerm_resource_group.default.location
  resource_group_name       =  azurerm_resource_group.default.name
  offer_type                = "Standard"
  kind                      = "GlobalDocumentDB"
  enable_automatic_failover = true
    
  capabilities {
    name = "EnableTable"
  }

  enable_multiple_write_locations = true
  consistency_policy {
    consistency_level       = "Session"
  }

  geo_location {
    location          = azurerm_resource_group.default.location
    failover_priority = 0
  }
}

resource "azurerm_cosmosdb_table" "default" {
  name                = "cosmos-db-table"
  resource_group_name = azurerm_cosmosdb_account.default.resource_group_name
  account_name        = azurerm_cosmosdb_account.default.name
  throughput          = 400
}

output "cosmosdb_connection_string0" {
    value = azurerm_cosmosdb_account.default.connection_strings[0]
}

output "cosmosdb_connection_string1" {
    value = azurerm_cosmosdb_account.default.connection_strings[1]
}

output "cosmosdb_connection_string2" {
    value = azurerm_cosmosdb_account.default.connection_strings[2]
}

output "cosmosdb_connection_string3" {
    value = azurerm_cosmosdb_account.default.connection_strings[3]
}

output "cosmosdb_connection_string" {
    value = azurerm_cosmosdb_account.default.endpoint
}


output "cosmosdb_connection_primary_key" {
    value = azurerm_cosmosdb_account.default.primary_key
}

@dzmitry-lahoda
Copy link
Contributor Author

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Outputs:

cosmosdb_connection_primary_key = "Ob2LgUinQB7RN6xjLmCcpoNTSpzFYI69qvtL6OeWCCIcpaVxfpBfLnzOduKvNs8NWwP0ZnqIHdyhLLjlt44mFA=="
cosmosdb_connection_string = "https://cosmos-lahodatf.documents.azure.com:443/"
cosmosdb_connection_string0 = "AccountEndpoint=https://cosmos-lahodatf.documents.azure.com:443/;AccountKey=Ob2LgUinQB7RN6xjLmCcpoNTSpzFYI69qvtL6OeWCCIcpaVxfpBfLnzOduKvNs8NWwP0ZnqIHdyhLLjlt44mFA==;"
cosmosdb_connection_string1 = "AccountEndpoint=https://cosmos-lahodatf.documents.azure.com:443/;AccountKey=CFIoPX5bszG1Qv8B2dSJJ0uhDaUTumAuIfB55PZRxG2jjc7wNTxWzQTPsStQje7BA51sS7hulJi7j3Ke84MpkA==;"
cosmosdb_connection_string2 = "AccountEndpoint=https://cosmos-lahodatf.documents.azure.com:443/;AccountKey=816WdxtGZGLabXZOPLLVbEhWwLtWimXZBG5Rt1XcYnZ4w1Y16KusX2HbTFTA4mdCD9C3GXJqvF6dMrq43HU7Jw==;"
cosmosdb_connection_string3 = "AccountEndpoint=https://cosmos-lahodatf.documents.azure.com:443/;AccountKey=HzCDW8EUPy0fvECU0BVYIomsURSsA9Nl6wslSs4R2zSWA7MgPp9PZ6yREHbTZ5ulFclXISQS0pXQIdBssqezrA==;"
D:\tmp\terraform\step8>

@dzmitry-lahoda
Copy link
Contributor Author

# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.

provider "registry.terraform.io/hashicorp/azurerm" {
  version = "2.41.0"
{
  "version": 4,
  "terraform_version": "0.14.3",
  "serial": 10,

@dzmitry-lahoda
Copy link
Contributor Author

dzmitry-lahoda commented Dec 23, 2020

any endpoints on account return documents, while table tf stuff does not have any connection info.

i glue stuff via interpolation/index/keys/regions.

@tombuildsstuff tombuildsstuff changed the title cosmos db table connection string r/cosmosdb_table: expose connection strings Jan 4, 2021
@dzmitry-lahoda
Copy link
Contributor Author

poor man connection string value = "DefaultEndpointsProtocol=https;AccountName=${azurerm_cosmosdb_account.global[0].name};AccountKey=${azurerm_cosmosdb_account.global[0].primary_key};TableEndpoint=https://${azurerm_cosmosdb_account.global[0].name}.table.cosmos.azure.com:443/;"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants