-
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_mysql_flexible_server
- convert public_network_access_enabled
from attribute to argument
#28890
base: main
Are you sure you want to change the base?
Conversation
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), |
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.
Are these Check
s made unnecessary by the ImportStep
s?
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.
We have it here to confirm it exists in Azure. Sometimes it doesn't even though it created because Azure is weird. You're probably right that we don't need it if we're checking import but it only costs an extra api call to doubly make sure it at least exists in Azure before we move on. Similar to how we had those old checks that we don't do anymore, we might move in that direction of removing this as well but for now, let's keep it consistent with how we do other tests
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.
Roger. I was considering removing them, but I looked through the code base and couldn't find any precedent of test steps without checks, so I left them in.
@@ -1359,3 +1388,20 @@ resource "azurerm_mysql_flexible_server" "test" { | |||
} | |||
`, r.template(data), acceptance.WriteOnlyKeyVaultSecretTemplate(data, secret), data.RandomInteger, version) | |||
} | |||
|
|||
func (r MySqlFlexibleServerResource) publicNetworkAccess(data acceptance.TestData, publicNetworkAccessEnabled string) string { |
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.
NB: I made publicNetworkAccessEnabled
a string (i.e. not a boolean) so it could be true
, false
or null
.
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.
Hey @wyattfry, looks good but I've just got some questions around a few areas before giving it a final sign off
"public_network_access_enabled": { | ||
Type: pluginsdk.TypeBool, | ||
Optional: true, | ||
Computed: true, |
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.
Do we know if this is defaulted to something if we create it? We could default it rather than Compute it if so
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.
Yes, Azure defaults it to true
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.
Sweet! Then we can default it to True as well
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.
Swagger indicates that the value of publicNetworkAccess is "Disabled" when server has VNet integration. Could you double confirm that the default value is always "Enabled"?
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.
Thanks Neil! I will test it.
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), |
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.
We have it here to confirm it exists in Azure. Sometimes it doesn't even though it created because Azure is weird. You're probably right that we don't need it if we're checking import but it only costs an extra api call to doubly make sure it at least exists in Azure before we move on. Similar to how we had those old checks that we don't do anymore, we might move in that direction of removing this as well but for now, let's keep it consistent with how we do other tests
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.publicNetworkAccess(data, "null"), |
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.
We normally don't test null but we might want to so I'm curious what are you hoping to see out of this test step and whether we should do this going forward?
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.
Testing the default behavior. The Azure REST API has the public access enabled as optional, so it doesn't need to be sent, so this is just to ensure we don't have one of those Computed / Optional situations I like had before, where when not specified, the first plan after the initial create wants to change the setting to the zero value.
But if we set a default on the Terraform layer that matches the default on the Azure layer, then testing with null here would be less valuable.
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.
Yea...so I think since Azure defaults public_network_access enabled to true, we can also default it to true and then don't have to test null
@@ -243,6 +243,12 @@ func resourceMysqlFlexibleServer() *pluginsdk.Resource { | |||
ValidateFunc: privatezones.ValidatePrivateDnsZoneID, | |||
}, | |||
|
|||
"public_network_access_enabled": { |
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.
One more note here, Microsoft is adding more options to public_network_access_enabled
so a boolean won't work when that change gets added. We should rename this to public_network_access
and have it be a string
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.
Roger, thanks! Will do.
Community Note
Description
This PR converts the existing attribute
public_network_access_enabled
into an optional argument, defaulting totrue
.PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
I only included the test results for the one I added that just tests the property in question and not all the other tests for this service because most of the other ones have been failing for months and are worth discussing as a team before trying to fix them.
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_mysql_flexible_server
- convertpublic_network_access_enabled
from attribute to argument [GH-XXXX]This is a (please select all that apply):
Related Issue(s)
Fixes #26156
Note
If this PR changes meaningfully during the course of review please update the title and description as required.