-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Add availability zone support #811
Add availability zone support #811
Conversation
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 @nordbergm
Thanks for opening this PR :)
I've taken a look through and left some comments in-line - but this mostly looks good to me. Since this functionality is in Public Preview (where users can self register) - we should be able to add this functionality providing we add an info box stating how users can join in the Preview (I've added an example info box in a comment).
Thanks!
storage_account_type = "Standard_LRS" | ||
create_option = "Empty" | ||
disk_size_gb = "1" | ||
zones = ["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.
minor can we fix the spacing here?
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
public_ip_address_allocation = "static" | ||
zones = ["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.
minor could we make the spacing consistent here?
|
||
os_profile_linux_config { | ||
disable_password_authentication = false | ||
} |
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.
minor could we make the spacing consistent here?
} | ||
|
||
storage_profile_os_disk { | ||
name = "" |
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.
I believe this is defaulted if not set, so I don't think we need to specify this?
azurerm/zones.go
Outdated
} | ||
} | ||
|
||
func zoneValuesToStrings(v []interface{}) *[]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.
we'd tend to name this expandZones
(since it's parsing the values out) - can we update this to match?
@@ -246,6 +246,7 @@ The following arguments are supported: | |||
* `network_interface_ids` - (Required) Specifies the list of resource IDs for the network interfaces associated with the virtual machine. | |||
* `primary_network_interface_id` - (Optional) Specifies the resource ID for the primary network interface associated with the virtual machine. | |||
* `tags` - (Optional) A mapping of tags to assign to the resource. | |||
* `zones` - (Optional) A collection containing the availability zone to allocate the Virtual Machine in. |
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.
can we add a note (blue box) that this functionality is in Preview:
-> **Please Note**: Availability Zones are [in Preview and only supported in several regions at this time](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview) - as such you must be opted into the Preview to use this functionality. You can [opt into the Availability Zones Preview in the Azure Portal](http://aka.ms/azenroll).
@@ -60,6 +60,8 @@ The following arguments are supported: | |||
|
|||
* `tags` - (Optional) A mapping of tags to assign to the resource. | |||
|
|||
* `zones` - (Optional) A collection containing the availability zone to allocate the Public IP in. |
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.
can we add a note (blue box) that this functionality is in Preview:
-> **Please Note**: Availability Zones are [in Preview and only supported in several regions at this time](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview) - as such you must be opted into the Preview to use this functionality. You can [opt into the Availability Zones Preview in the Azure Portal](http://aka.ms/azenroll).
@@ -106,6 +106,8 @@ The following arguments are supported: | |||
|
|||
* `tags` - (Optional) A mapping of tags to assign to the resource. | |||
|
|||
* `zones` - (Optional) A collection containing the availability zone to allocate the Managed Disk in. |
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.
can we add a note (blue box) that this functionality is in Preview:
-> **Please Note**: Availability Zones are [in Preview and only supported in several regions at this time](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview) - as such you must be opted into the Preview to use this functionality. You can [opt into the Availability Zones Preview in the Azure Portal](http://aka.ms/azenroll).
@@ -58,6 +58,7 @@ The following arguments are supported: | |||
* `private_ip_address` - (Optional) Private IP Address to assign to the Load Balancer. The last one and first four IPs in any range are reserved and cannot be manually assigned. | |||
* `private_ip_address_allocation` - (Optional) Defines how a private IP address is assigned. Options are Static or Dynamic. | |||
* `public_ip_address_id` - (Optional) Reference to Public IP address to be associated with the Load Balancer. | |||
* `zones` - (Optional) A collection containing the availability zone to allocate the IP in. |
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.
can we add a note (blue box) that this functionality is in Preview:
-> **Please Note**: Availability Zones are [in Preview and only supported in several regions at this time](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview) - as such you must be opted into the Preview to use this functionality. You can [opt into the Availability Zones Preview in the Azure Portal](http://aka.ms/azenroll).
@@ -111,3 +111,4 @@ resource "azurerm_virtual_machine" "test" { | |||
* `os_type` - The operating system for managed disk. Valid values are `Linux` or `Windows` | |||
* `disk_size_gb` - The size of the managed disk in gigabytes. | |||
* `tags` - A mapping of tags assigned to the resource. | |||
* `zones` - (Optional) A collection containing the availability zone the managed disk is allocated in. |
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.
can we add a note (blue box) that this functionality is in Preview:
-> **Please Note**: Availability Zones are [in Preview and only supported in several regions at this time](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview) - as such you must be opted into the Preview to use this functionality. You can [opt into the Availability Zones Preview in the Azure Portal](http://aka.ms/azenroll).
Fixes #370 |
c3b7916
to
94cc4ee
Compare
hey @tombuildsstuff, Thanks for the review! Your pointers should be sorted now, but let me know if there's anything else. |
@@ -135,7 +138,8 @@ func resourceArmManagedDiskCreate(d *schema.ResourceData, meta interface{}) erro | |||
Sku: &compute.DiskSku{ | |||
Name: (skuName), | |||
}, | |||
Tags: expandedTags, | |||
Tags: expandedTags, | |||
Zones: zones, |
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.
Given we set this value always - if a user isn't opted into the Preview most deployments will fail:
* azurerm_managed_disk.test: compute.DisksClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ResourceTypeNotSupportAvailabilityZones" Message="The resource type 'disks' does not support availability zones at location 'westeurope' and api-version '2017-03-30'."
Can we instead change this to assign Zones only if the field is set? e.g.
if v, ok := d.Get("zones"); ok {
zones := expandZones(v.([]interface{}))
createDisk.Zones = zones
}
which should remove this error
frontEndConfig := network.FrontendIPConfiguration{ | ||
Name: &name, | ||
FrontendIPConfigurationPropertiesFormat: &properties, | ||
Zones: zones, |
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.
from what I can see, this will be the same issue as below (where a user isn't opted into the Preview, this fails) - can we update it to use the pattern identified below?
@@ -157,7 +160,8 @@ func resourceArmPublicIpCreate(d *schema.ResourceData, meta interface{}) error { | |||
Location: &location, | |||
Sku: &sku, | |||
PublicIPAddressPropertiesFormat: &properties, | |||
Tags: expandTags(tags), | |||
Tags: expandTags(tags), | |||
Zones: zones, |
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.
from what I can see, this will be the same issue as above (where a user isn't opted into the Preview, this fails) - can we update it to use the pattern identified below?
@@ -577,7 +580,8 @@ func resourceArmVirtualMachineCreate(d *schema.ResourceData, meta interface{}) e | |||
Name: &name, | |||
Location: &location, | |||
VirtualMachineProperties: &properties, | |||
Tags: expandedTags, | |||
Tags: expandedTags, | |||
Zones: zones, |
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.
from what I can see, this will be the same issue as above (where a user isn't opted into the Preview, this fails) - can we update it to use the pattern identified below?
@@ -564,6 +566,7 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf | |||
location := d.Get("location").(string) | |||
resGroup := d.Get("resource_group_name").(string) | |||
tags := d.Get("tags").(map[string]interface{}) | |||
zones := expandZones(d.Get("zones").([]interface{})) |
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.
from what I can see, this will be the same issue as above (where a user isn't opted into the Preview, this fails) - can we update it to use the pattern identified below?
@@ -632,6 +635,7 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf | |||
Tags: expandTags(tags), | |||
Sku: sku, | |||
VirtualMachineScaleSetProperties: &scaleSetProps, | |||
Zones: zones, |
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.
from what I can see, this will be the same issue as above (where a user isn't opted into the Preview, this fails) - can we update it to use the pattern identified below?
hey @nordbergm Thanks for pushing those updates - I kicked off the test suite here without the Preview enabled (to confirm the existing tests work) - however the existing tests fail as we're setting the Zones field regardless:
Can we update the assignment of the Thanks! |
hey @tombuildsstuff, Sorry about those test failures. I initially looked at the Azure Go client and how Zones *[]string `json:"zones,omitempty"` My expectation was that it would omit an empty array from the request. After some testing it seems this is generally the case, but since the field is defined as a pointer, the pointer has to be A perhaps simpler and more central change, would be to have |
@tombuildsstuff I pushed an example of my suggested approach. Let me know what you think, and if you still experience any issues with the tests. |
@tombuildsstuff is the approach @nordbergm pushed ok? Any updates are appreciated |
@agup006 @nordbergm sorry for the delay in re-reviewing this - we're trying to work through the review backlog - I'm taking a look into this now. |
azurerm/resource_arm_loadbalancer.go
Outdated
@@ -306,6 +310,7 @@ func flattenLoadBalancerFrontendIpConfiguration(ipConfigs *[]network.FrontendIPC | |||
for _, config := range *ipConfigs { | |||
ipConfig := make(map[string]interface{}) | |||
ipConfig["name"] = *config.Name | |||
ipConfig["zones"] = *config.Zones |
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.
so there's a crash here if config.Zones
is nil - can we make this:
zones := make([]string, 0)
if zs := config.Zones; zs != nil {
for _, zone := range *zs {
zones = append(zones, zone)
}
}
ipConfig["zones"] = zones
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.
I hope you don't mind, but I've pushed a commit to fix this
hey @nordbergm @agup006 Thanks for pushing the latest updates - apologies about the delayed review here! The latest updates looks good, however running the tests there appears to be a crash in the Load Balancer resource (which I've commented in-line about) If we can sort that out, we'll take another look through/kick of the tests - but this should be good :) Thanks! Tests: Data Source tests pass: Managed Disk resource tests pass: Public Ip tests pass: Reminder of the test prefixes for me, for later:
|
Tests pass: ``` $ acctests azurerm TestAccAzureRMLoadBalancer_basic === RUN TestAccAzureRMLoadBalancer_basic --- PASS: TestAccAzureRMLoadBalancer_basic (59.25s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 59.281s ```
77ad002
to
5bc57f1
Compare
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 @nordbergm
I've pushed a commit to fix the crash identified in the tests and ran the tests - and this now LGTM 👍
Thanks!
Thanks @tombuildsstuff! |
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
Hey all,
This PR adds availability zone support to resources that are included in the AZ public preview. I'm unclear on what the policy is on preview features in Terraform, but it would be great if we could get this in.
It should also address feature request #370.
Updated Resources
azurerm_virtual_machine
azurerm_virtual_machine_scale_set
azurerm_public_ip
azurerm_managed_disk
azurerm_lb
Updated Data Sources
azurerm_managed_disk