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

Error parsing azurerm_cosmosdb_account resource id #24811

Closed
1 task done
ajaffie opened this issue Feb 7, 2024 · 5 comments
Closed
1 task done

Error parsing azurerm_cosmosdb_account resource id #24811

ajaffie opened this issue Feb 7, 2024 · 5 comments

Comments

@ajaffie
Copy link

ajaffie commented Feb 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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 and review the contribution guide to help.

Terraform Version

1.6

AzureRM Provider Version

3.90

Affected Resource(s)/Data Source(s)

azurerm_cosmosdb_account

Terraform Configuration Files

# Anything with a azurerm_cosmosdb_account

Debug Output/Panic Output

╷
│ Error: parsing "/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.DocumentDb/databaseAccounts/<name>": parsing segment "staticMicrosoftDocumentDB": parsing the DatabaseAccount ID: the segment at position 5 didn't match

│ Expected a DatabaseAccount ID that matched:

│ > /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountValue

│ However this value was provided:

│ > /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.DocumentDb/databaseAccounts/<name>

│ The parsed Resource ID was missing a value for the segment at position 5
│ (which should be the name of the Resource Provider [for example 'Microsoft.DocumentDB']).

Expected Behaviour

It should not have trouble parsing the resource id.

Actual Behaviour

It could not parse the resource id.

Steps to Reproduce

No response

Important Factoids

It is not an issue on 3.85, I haven't tested any versions in between.

References

No response

@bramvdklinkenberg
Copy link
Contributor

Works with 3.88.

In 3.89 there was an enhancement cosmosdb: updating to API Version 2023-04-15. Link to PR

I don't see any cosmosdb changes in the release notes for 3.90.1, so assuming the issue is still there in that version.

@leowaisblatt
Copy link

FYI, not working for me with version 3.88 either.

Works with 3.88.

In 3.89 there was an enhancement cosmosdb: updating to API Version 2023-04-15. Link to PR

I don't see any cosmosdb changes in the release notes for 3.90.1, so assuming the issue is still there in that version.

@tombuildsstuff
Copy link
Contributor

hey @ajaffie @leowaisblatt @bramvdklinkenberg

Taking a look through here it appears that the CosmosDB Account was imported previously using a Resource ID which differs from the casing we’re expecting for a CosmosDB Account, which is why this parsing is failing.

Unfortunately there’s not enough information in the issue to confirm that for sure (it could also be coming from an associated resource, we'd need debug logs/a terraform configuration to confirm otherwise) - but you should be able to validate this using terraform show to check the ID field for the CosmosDB Account in question. Per the error message in question, it appears that Microsoft.DocumentDb is present within the Resource ID rather than Microsoft.DocumentDB, which is the expected casing.

Once that’s confirmed, you should be able to use terraform state rm azurerm_cosmosdb_account.[name] and terraform import azurerm_cosmosdb_account.[name] [updated resource id] to fix the Resource ID for this resource, which’ll fix this issue.

As per the documentation for this resource and the error message being returned here, the expected Resource ID for a CosmosDB Account is:

/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountValue

However since there isn’t a repro for this in the description for this issue, or any debug logs attached - unfortunately that’s all we’ve got to go on here - and as such this appears to be an issue with the Resource that’s been imported previously.

As updating the Resource ID for the Resource will resolve that issue - I believe this’ll resolve that and so I’m going to close this issue for the moment - but if this doesn’t resolve this for you then if you can attach some debug logs, a Terraform Configuration and the output from terraform show then we can take another look.

Thanks!

@leowaisblatt
Copy link

@tombuildsstuff your suggestion of removing the resource from the state and importing it back did work well. Thanks a lot!

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
Development

No branches or pull requests

5 participants