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_private_endpoint - correct casing issue for private_connection_resource_id field for Microsoft.DBforPostgreSQL #12761

Merged
merged 4 commits into from
Jul 28, 2021

Conversation

yupwei68
Copy link
Contributor

There is a ticket from customer.
The customer created a Private Endpoint through portal connecting to a postgresql server.
The PE created is with "PrivateConnectionId" "...Microsoft.DBForPostgreSQL.." instead of "...Microsoft.DBforPostgreSQL..." (wrong casing "F").
Then he imports the PE into TF, and the TF requires a recreation of the PE.
Here we support to be compatible with this problem.

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

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

@yupwei68, thanks for the PR. LGTM! 🚀

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

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

@yupwei68, given this change the return signature of this function also needs to be updated to bubble up the err to the caller since an error may now occur during the parse of the ServerID code execution. Which means if an error does happen with the new code path the new privateConnectionId would be ""?

@yupwei68
Copy link
Contributor Author

@WodansSon Thanks for your comments. When parse returns error, it could be "postgresql flexible server" or other resources, thus I don't change its origin value, it'll be "privateConnectionId = *props.PrivateLinkServiceID" instead of "".
Just when the parse returns no error, I'll change its value to our self-make id.

@WodansSon
Copy link
Collaborator

@WodansSon Thanks for your comments. When parse returns error, it could be "postgresql flexible server" or other resources, thus I don't change its origin value, it'll be "privateConnectionId = *props.PrivateLinkServiceID" instead of "".
Just when the parse returns no error, I'll change its value to our self-make id.

Ahhh... I see what you are saying... if the return value from the GET call contains microsoft.dbforpostgresql we will attempt to parse the value with our parse function. If that returns an error we will ignore the error and set the value to whatever was returned by the GET call, but if the parse function succeeds we will replace the value with our normalized value, which should fix the issue we are currently seeing for this particular edge case. @mybayern1974 , good catch on the != I totally missed that, I think I am just really tired... it's been a long day... thanks for that. 🙂

@yupwei68
Copy link
Contributor Author

Thanks @WodansSon and @mybayern1974 for your review.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hi @yupwei68

Thanks for this PR.

This looks fine, but I'm wondering if we need to consider this for all of the DBFor resources, due to the changes in the Azure SDK in v55.7.0 - WDYT?

Thanks!

@WodansSon WodansSon changed the title Help to be compatible with bug from ARM Cache in private_endpoint private_connection_resource_id pointing to a postgresql server azurerm_private_endpoint - correct casing issue for private_connection_resource_id field for Microsoft.DBforPostgreSQL Jul 28, 2021
@WodansSon WodansSon added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Jul 28, 2021
@github-actions github-actions bot added size/S and removed size/XS labels Jul 28, 2021
@yupwei68
Copy link
Contributor Author

Thanks for your comments. Please continue reviewing.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@tombuildsstuff tombuildsstuff added this to the v2.70.0 milestone Jul 28, 2021
@tombuildsstuff
Copy link
Contributor

Tests pass:

Screenshot 2021-07-28 at 18 29 38

@tombuildsstuff tombuildsstuff merged commit ba74dcd into hashicorp:master Jul 28, 2021
tombuildsstuff added a commit that referenced this pull request Jul 28, 2021
@yupwei68
Copy link
Contributor Author

When importing a PE from portal, possibly the user need to change the hardcode private_connection_resource_id from "Microsoft.DBForPostgreSQL" to "Microsoft.DBforPostgreSQL"

@github-actions
Copy link

This functionality has been released in v2.70.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

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 Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/private-link size/S upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants