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

azurerm_cosmosdb_mongo_collection isn't tracking default_ttl_seconds or indexes #7825

Closed
marc-sensenich opened this issue Jul 21, 2020 · 5 comments

Comments

@marc-sensenich
Copy link
Contributor

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

terraform version
Terraform v0.12.26
+ provider.azurerm v2.19.0

Affected Resource(s)

  • azurerm_cosmosdb_mongo_collection

Terraform Configuration Files

resource "azurerm_cosmosdb_mongo_collection" "test" {
  name                = "acctest-01"
  resource_group_name = azurerm_cosmosdb_mongo_database.test.resource_group_name
  account_name        = azurerm_cosmosdb_mongo_database.test.account_name
  database_name       = azurerm_cosmosdb_mongo_database.test.name
  default_ttl_seconds = 707
  throughput          = 400

  index {
    keys   = ["seven", "six"]
    unique = true
  }

  index {
    keys   = ["day"]
    unique = false
  }

  index {
    keys = ["month"]
  }
}

Expected Behavior

The index and default_ttl_seconds fields should not need to be updated after an apply.

Actual Behavior

The index and default_ttl_seconds fields attempt to update or get created after an apply.

$ terraform apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_cosmosdb_mongo_collection.test will be created
  + resource "azurerm_cosmosdb_mongo_collection" "test" {
      + account_name        = "redacted"
      + database_name       = "redacted"
      + default_ttl_seconds = 707
      + id                  = (known after apply)
      + name                = "acctest-01"
      + resource_group_name = "redacted"
      + system_indexes      = (known after apply)
      + throughput          = 400

      + index {
          + keys   = [
              + "day",
            ]
          + unique = false
        }
      + index {
          + keys   = [
              + "month",
            ]
          + unique = false
        }
      + index {
          + keys   = [
              + "seven",
              + "six",
            ]
          + unique = true
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

azurerm_cosmosdb_mongo_collection.test: Creating...
azurerm_cosmosdb_mongo_collection.test: Still creating... [10s elapsed]
azurerm_cosmosdb_mongo_collection.test: Still creating... [20s elapsed]
azurerm_cosmosdb_mongo_collection.test: Still creating... [30s elapsed]
azurerm_cosmosdb_mongo_collection.test: Still creating... [40s elapsed]
azurerm_cosmosdb_mongo_collection.test: Still creating... [50s elapsed]
azurerm_cosmosdb_mongo_collection.test: Still creating... [1m0s elapsed]
azurerm_cosmosdb_mongo_collection.test: Creation complete after 1m4s [id=/subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.DocumentDB/databaseAccounts/redacted/apis/mongodb/databases/testing/collections/acctest-01]

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

$ terraform state show azurerm_cosmosdb_mongo_collection.test
# azurerm_cosmosdb_mongo_collection.test:
resource "azurerm_cosmosdb_mongo_collection" "test" {
    account_name        = "redacted"
    database_name       = "redacted"
    default_ttl_seconds = 0
    id                  = "/subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.DocumentDB/databaseAccounts/redacted/apis/mongodb/databases/testing/collections/acctest-01"
    name                = "acctest-01"
    resource_group_name = "redacted"
    system_indexes      = [
        {
            keys   = [
                "DocumentDBDefaultIndex",
            ]
            unique = false
        },
    ]
    throughput          = 400

    index {
        keys   = [
            "day",
        ]
        unique = false
    }
    index {
        keys   = [
            "month",
        ]
        unique = false
    }
    index {
        keys   = [
            "seven",
            "six",
        ]
        unique = true
    }
}

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

azurerm_cosmosdb_mongo_collection.test: Refreshing state... [id=/subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.DocumentDB/databaseAccounts/redacted/apis/mongodb/databases/testing/collections/acctest-01]

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # azurerm_cosmosdb_mongo_collection.test will be updated in-place
  ~ resource "azurerm_cosmosdb_mongo_collection" "test" {
        account_name        = "redacted"
        database_name       = "redacted"
      ~ default_ttl_seconds = 0 -> 707
        id                  = "/subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.DocumentDB/databaseAccounts/redacted/apis/mongodb/databases/testing/collections/acctest-01"
        name                = "acctest-01"
        resource_group_name = "redacted"
        system_indexes      = [
            {
                keys   = [
                    "DocumentDBDefaultIndex",
                ]
                unique = false
            },
        ]
        throughput          = 400

      + index {
          + keys   = [
              + "day",
            ]
          + unique = false
        }
      + index {
          + keys   = [
              + "month",
            ]
          + unique = false
        }
      + index {
          + keys   = [
              + "seven",
              + "six",
            ]
          + unique = true
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

------------------------------------------------------------------------

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Important Factoids

This looks to be a change in response for the get Mongo DB collection API

az resource show --api-version 2015-04-08 --ids /subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.DocumentDB/databaseAccounts/redacted/apis/mongodb/databases/testing/collections/acctest-01
{
  "id": "/subscriptions/redacted/resourceGroups/redacted/providers/Microsoft.DocumentDB/databaseAccounts/redacted/apis/mongodb/databases/testing/collections/acctest-01",
  "identity": null,
  "kind": null,
  "location": null,
  "managedBy": null,
  "name": "acctest-01",
  "plan": null,
  "properties": {
    "_etag": "\"00005111-0000-0100-0000-5f16bf010000\"",
    "_rid": "y0ERAL8i5eM=",
    "_ts": 1595326209,
    "id": "acctest-01",
    "indexes": [
      {
        "key": {
          "keys": [
            "DocumentDBDefaultIndex"
          ]
        },
        "options": {}
      }
    ]
  },
  "resourceGroup": "redacted",
  "sku": null,
  "tags": null,
  "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases/collections"
}
@yupwei68
Copy link
Contributor

Hi @marc-sensenich Thanks for opening this issue. TTL field has been fixed and released last week. I have checked and all the acctests in azurerm_cosmosdb_mongo_collection have been tested with pass.

@RichardNixon52
Copy link

Any update on indexes?

@favoretti
Copy link
Contributor

@marc-sensenich is this still happening or can this be closed now?

@marc-sensenich
Copy link
Contributor Author

@favoretti, this can be closed based on the fix by @yupwei68

@github-actions
Copy link

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 Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants