-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_postgresql_flexible_server_virtual_endpoint
- validate with PostgresqlFlexibleServerVirtualEndpointIDInsensitively
#28418
Conversation
…ostgresqlFlexibleServerVirtualEndpointIDInsensitively
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neil-yechenwei are you able to reproduce the error in the linked issue?
I created a virtual endpoint in the portal with the ID
/subscriptions/***/resourceGroups/bcctest/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-sw/virtualendpoints/acctest-ve-sw
and was able to import it successfully with camel cased virtualEndpoints
$ terraform import azurerm_postgresql_flexible_server_virtual_endpoint.test /subscriptions/***/resourceGroups/bcctest/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-sw/virtualEndpoints/acctest-ve-sw
data.azurerm_subscription.test: Reading...
azurerm_postgresql_flexible_server_virtual_endpoint.test: Importing from ID "/subscriptions/***/resourceGroups/bcctest/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-sw/virtualEndpoints/acctest-ve-sw"...
azurerm_postgresql_flexible_server_virtual_endpoint.test: Import prepared!
Prepared azurerm_postgresql_flexible_server_virtual_endpoint for import
azurerm_postgresql_flexible_server_virtual_endpoint.test: Refreshing state... [id=/subscriptions/***/resourceGroups/bcctest/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-sw/virtualEndpoints/acctest-ve-sw]
data.azurerm_subscription.test: Read complete after 0s [id=/subscriptions/***]
Import successful!
@@ -40,7 +41,7 @@ func (r PostgresqlFlexibleServerVirtualEndpointResource) ResourceType() string { | |||
} | |||
|
|||
func (r PostgresqlFlexibleServerVirtualEndpointResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { | |||
return virtualendpoints.ValidateVirtualEndpointID | |||
return validate.PostgresqlFlexibleServerVirtualEndpointIDInsensitively |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under no circumstance should we be validating input IDs case insensitively. One of the main reasons for moving to the resource ID parsers and validators generated by Pandora is because they can validate IDs case sensitively and prevent IDs with inconsistent casing from from entering a user's config and state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the current issue, if we don't use xxxInsensitively at this point, the following error will occur during the import process.
Error Message:
azurerm_postgresql_flexible_server_virtual_endpoint.test: Importing from ID "/subscriptions/xx-xx-xx-xx/resourceGroups/acctest-ve-rg-test01/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-test01/virtualendpoints/acctest-ve-test01"...
╷
│ Error: parsing "/subscriptions/xx-xx-xx-xx/resourceGroups/acctest-ve-rg-test01/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-test01/virtualendpoints/acctest-ve-test01": parsing segment "staticVirtualEndpoints": parsing the VirtualEndpoint ID: the segment at position 8 didn't match
│
│ Expected a VirtualEndpoint ID that matched:
│
│ > /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints/virtualEndpointName
│
│ However this value was provided:
│
│ > /subscriptions/xx-xx-xx-xx/resourceGroups/acctest-ve-rg-test01/providers/Microsoft.DBforPostgreSQL/flexibleServers/acctest-ve-primary-test01/virtualendpoints/acctest-ve-test01
│
│ The parsed Resource ID was missing a value for the segment at position 8
│ (which should be the literal value "virtualEndpoints").
@stephybun , yes. I reproduced this issue with Error message:
|
Yes, this is the reason why we try to ensure the example import ID in the documentation always matches the casing that we're expecting in the ID parsers/validators for that resource. There are two errors described in linked issue, from what you've described you reproduced the second error that was pasted in the issue which is that the provider returns a validation error when trying to import the resource with the ID segment I tried to reproduce the first error by
I expected to get the following error but didn't, it imported successfully.
Can you please see if you can reproduce this part of the issue? |
For the first error, if my understanding is correct, the user was just using a fake resource ID to test the functionality of terraform import, so this is expected. Since both errors are expected behaviors, I will close this PR. |
Community Note
Description
Though the resource ID of Postgresql fs virtual endpoint is with the segment "virtualendpoints" on Swagger but the resource ID on the generated go azure sdk is with the segment "virtualEndpoints". So I will use the "xxxInsensitively" func to resolve this issue.
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_postgresql_flexible_server_virtual_endpoint
- validate withPostgresqlFlexibleServerVirtualEndpointIDInsensitively
This is a (please select all that apply):
Related Issue(s)
Fixes #28410
Note
If this PR changes meaningfully during the course of review please update the title and description as required.