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: Fix the issue that expireAfterSeconds property could not be set to -1 #15736

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

sinbai
Copy link
Contributor

@sinbai sinbai commented Mar 8, 2022

The purpose of this PR:

Currently, there is such a description of default_ttl_seconds in terraform doc, when the value of default_ttl_seconds is set to -1 or 0, it means the collection never expires(The default_ttl_seconds property in Terraform aka the expireAfterSeconds in API). After checking tf code, if default_ttl_seconds <=0 in tf configuration, then terraform will not add "_ts" index and set value of expireAfterSeconds to the value of default_ttl_seconds. Per the doc (TTL behavior for mongoDB collection(container) is the same as SQL, confirmed by service team), it causes the document(item) to never expire despite the ttl of document level being set to a valid value.

In fact, when default_ttl_seconds is set to -1, terraform should set expireAfterSeconds to -1. Also, it is confirmed that 0 is not supported for expireAfterSeconds property. So, the updates are as follows:

• Create a "_ts" index with `expireAfterSeconds` value of -1 when `default_ttl_seconds` is set to -1.
• Update the tf doc to clarify that -1 means never expired.
• Update the validation of `default_ttl_seconds` to allow only a nonzero positive integer, or '-1'.
• Add test case to cover never expires.

Test Results:

PASS: TestAccCosmosDbMongoCollection_serverless (1558.45s)
PASS: TestAccCosmosDbMongoCollection_withIndex (1574.87s)
PASS: TestAccCosmosDbMongoCollection_neverExpires (1580.70s)
PASS: TestAccCosmosDbMongoCollection_basic (1581.52s)
PASS: TestAccCosmosDbMongoCollection_complete (1581.69s)
PASS: TestAccCosmosDbMongoCollection_autoscaleWithoutShareKey (1582.70s)
PASS: TestAccCosmosDbMongoCollection_ver36 (1590.43s)
PASS: TestAccCosmosDbMongoCollection_analyticalStorageTTL (1596.17s)
PASS: TestAccCosmosDbMongoCollection_throughput (1803.67s)
PASS: TestAccCosmosDbMongoCollection_update (1844.47s)
PASS: TestAccCosmosDbMongoCollection_autoscale (1877.26s)

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sinbai - LGTM 👍

@katbyte katbyte merged commit 655919b into hashicorp:main Mar 17, 2022
@github-actions github-actions bot added this to the v3.0.0 milestone Mar 17, 2022
katbyte added a commit that referenced this pull request Mar 17, 2022
@github-actions
Copy link

This functionality has been released in v3.0.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented May 6, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants