-
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_virtual_machine_scale_set - prevent public_ip_address_configuration
from being lost during update
#3767
azurerm_virtual_machine_scale_set - prevent public_ip_address_configuration
from being lost during update
#3767
Conversation
Create the required acceptance tests that would show the issue as described in the ticket hashicorp#3763 Related: hashicorp#3763
The public_ip_configuration is configured as a `schema.TypeList` but when we actually parsing the response from the API its a map so we need to do some massage of the data to match what the TF definition expects. Fixes: hashicorp#3763
@@ -1331,8 +1331,9 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual | |||
publicIpConfigs := make([]map[string]interface{}, 0, 1) | |||
publicIpConfig := make(map[string]interface{}) | |||
publicIpConfig["name"] = *publicIpInfo.Name | |||
publicIpConfig["domain_name_label"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DNSSettings | |||
publicIpConfig["domain_name_label"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DNSSettings.DomainNameLabel |
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.
Nice catch!
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.
Indeed! We are going to definitely need to add some.. many nil checks to this as the original code was lacking many. My suggestion is something like this:
if ipCfg := properties.PublicIPAddressConfiguration; ipCfg != nil {
block := make(map[string]interface{})
if v := ipCfg.Name; v != nil {
block["name"] = *v
}
if ipProperties := ipCfg.VirtualMachineScaleSetPublicIPAddressConfigurationProperties; ipProperties != nil {
if dns := ipProperties.DNSSettings; dns != nil {
if v := dns.DomainNameLabel; v != nil {
block["domain_name_label"] = *v
}
}
if v := ipProperties.IdleTimeoutInMinutes; v != nil {
block["idle_timeout"] = *v
}
}
config["public_ip_address_configuration"] = []map[string]interface{}{block}
}
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.
Looks good!
Hi @jeffreyCline, the fix is very simple and appears to solve the problem. Do you think you could have a look for us? |
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.
Hi @alexsapran,
Thank you for spotting this and opening a PR to fix it! Aside from one comment i've left inline this LGTM 🙂 Once we add some nil checks there (and the tests pass) this will be good to merge
@@ -1331,8 +1331,9 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual | |||
publicIpConfigs := make([]map[string]interface{}, 0, 1) | |||
publicIpConfig := make(map[string]interface{}) | |||
publicIpConfig["name"] = *publicIpInfo.Name | |||
publicIpConfig["domain_name_label"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DNSSettings | |||
publicIpConfig["domain_name_label"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DNSSettings.DomainNameLabel |
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.
Indeed! We are going to definitely need to add some.. many nil checks to this as the original code was lacking many. My suggestion is something like this:
if ipCfg := properties.PublicIPAddressConfiguration; ipCfg != nil {
block := make(map[string]interface{})
if v := ipCfg.Name; v != nil {
block["name"] = *v
}
if ipProperties := ipCfg.VirtualMachineScaleSetPublicIPAddressConfigurationProperties; ipProperties != nil {
if dns := ipProperties.DNSSettings; dns != nil {
if v := dns.DomainNameLabel; v != nil {
block["domain_name_label"] = *v
}
}
if v := ipProperties.IdleTimeoutInMinutes; v != nil {
block["idle_timeout"] = *v
}
}
config["public_ip_address_configuration"] = []map[string]interface{}{block}
}
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.
@alexsapran @kwilczynski Thanks for the PR! This is great and mostly LGTM, just fix up the nil
checks and I think we are ready to merge this.
Hi @katbyte and @jeffreyCline, thank you so much for the review! I believe @alexsapran will be able to include the |
given that we just released last friday and there are only a handful unreleased so most likely release date will be next week. |
In order to follow the way we do nil checks in other places.
This commit adds some nil checks to the initial implementation.
Hi @jeffreyCline and @katbyte and thank you for taking the time to review my PR. I have pushed 2 new commits ea555d0 and 1498394. The first is just to follow the pattern of the nil checks and the second is to follow your recommendation around the additional Nil checks that you requested. Please let me know what do you think and if you are still +1 |
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 for the revisions @alexsapran, LGTM now 🙂
public_ip_address_configuration
from being lost during update
This has been released in version 1.32.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 1.32.0"
}
# ... other configuration ... |
Hi @katbyte, thank you so much for your help and for cutting the release. Much appreciated! |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Why
This commit is fixing #3763 when we perform a simple update on an existing scale-set the definition of the scale-set was changed on the
publicIPAddressConfiguration
field.This means that any new instances that would be started from the scale-set would not have public IPs when it would be expected to have public IP.
What
Start with creating some test coverage around the issue.
Fix the actual issue that caused the public ip configuration of a scale-set to be removed.
Fixes: #3763