-
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
Add availability zone support #811
Changes from 9 commits
7fa4231
a0057e0
5ba9fa3
3a6e00f
7296944
429caa8
3c18df8
a1a6939
66d6d1e
c2e5fdc
94cc4ee
4f02abd
5bc57f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,8 @@ func resourceArmLoadBalancer() *schema.Resource { | |
Elem: &schema.Schema{Type: schema.TypeString}, | ||
Set: schema.HashString, | ||
}, | ||
|
||
"zones": singleZonesSchema(), | ||
}, | ||
}, | ||
}, | ||
|
@@ -290,9 +292,11 @@ func expandAzureRmLoadBalancerFrontendIpConfigurations(d *schema.ResourceData) * | |
} | ||
|
||
name := data["name"].(string) | ||
zones := zoneValuesToStrings(data["zones"].([]interface{})) | ||
frontEndConfig := network.FrontendIPConfiguration{ | ||
Name: &name, | ||
FrontendIPConfigurationPropertiesFormat: &properties, | ||
Zones: zones, | ||
} | ||
|
||
frontEndConfigs = append(frontEndConfigs, frontEndConfig) | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. so there's a crash here if
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
if props := config.FrontendIPConfigurationPropertiesFormat; props != nil { | ||
ipConfig["private_ip_address_allocation"] = props.PrivateIPAllocationMethod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ func resourceArmManagedDisk() *schema.Resource { | |
|
||
"resource_group_name": resourceGroupNameSchema(), | ||
|
||
"zones": singleZonesSchema(), | ||
|
||
"storage_account_type": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
|
@@ -118,6 +120,7 @@ func resourceArmManagedDiskCreate(d *schema.ResourceData, meta interface{}) erro | |
osType := d.Get("os_type").(string) | ||
tags := d.Get("tags").(map[string]interface{}) | ||
expandedTags := expandTags(tags) | ||
zones := zoneValuesToStrings(d.Get("zones").([]interface{})) | ||
|
||
var skuName compute.StorageAccountTypes | ||
if strings.ToLower(storageAccountType) == strings.ToLower(string(compute.PremiumLRS)) { | ||
|
@@ -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 commentThe 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:
Can we instead change this to assign Zones only if the field is set? e.g.
which should remove this error |
||
} | ||
|
||
if v := d.Get("disk_size_gb"); v != 0 { | ||
|
@@ -221,6 +225,7 @@ func resourceArmManagedDiskRead(d *schema.ResourceData, meta interface{}) error | |
|
||
d.Set("name", resp.Name) | ||
d.Set("resource_group_name", resGroup) | ||
d.Set("zones", resp.Zones) | ||
|
||
if location := resp.Location; location != nil { | ||
d.Set("location", azureRMNormalizeLocation(*location)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,6 +304,30 @@ resource "azurerm_managed_disk" "test" { | |
`, rInt, location, rInt) | ||
} | ||
|
||
func testAccAzureRMManagedDisk_empty_withZone(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_managed_disk" "test" { | ||
name = "acctestd-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. minor can we fix the spacing here? |
||
|
||
tags { | ||
environment = "acctest" | ||
cost-center = "ops" | ||
} | ||
} | ||
`, rInt, location, rInt) | ||
} | ||
|
||
func testAccAzureRMManagedDisk_import(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ func resourceArmPublicIp() *schema.Resource { | |
|
||
"resource_group_name": resourceGroupNameSchema(), | ||
|
||
"zones": singleZonesSchema(), | ||
|
||
"public_ip_address_allocation": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
|
@@ -115,6 +117,7 @@ func resourceArmPublicIpCreate(d *schema.ResourceData, meta interface{}) error { | |
Name: network.PublicIPAddressSkuName(d.Get("sku").(string)), | ||
} | ||
tags := d.Get("tags").(map[string]interface{}) | ||
zones := zoneValuesToStrings(d.Get("zones").([]interface{})) | ||
|
||
ipAllocationMethod := network.IPAllocationMethod(d.Get("public_ip_address_allocation").(string)) | ||
|
||
|
@@ -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 commentThe 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? |
||
} | ||
|
||
future, err := client.CreateOrUpdate(ctx, resGroup, name, publicIp) | ||
|
@@ -206,6 +210,7 @@ func resourceArmPublicIpRead(d *schema.ResourceData, meta interface{}) error { | |
|
||
d.Set("name", resp.Name) | ||
d.Set("resource_group_name", resGroup) | ||
d.Set("zones", resp.Zones) | ||
if location := resp.Location; location != nil { | ||
d.Set("location", azureRMNormalizeLocation(*location)) | ||
} | ||
|
@@ -223,10 +228,10 @@ func resourceArmPublicIpRead(d *schema.ResourceData, meta interface{}) error { | |
if fqdn := settings.Fqdn; fqdn != nil { | ||
d.Set("fqdn", fqdn) | ||
} | ||
} | ||
|
||
if ip := props.IPAddress; ip != nil { | ||
d.Set("ip_address", ip) | ||
} | ||
if ip := props.IPAddress; ip != nil { | ||
d.Set("ip_address", ip) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,6 +344,23 @@ resource "azurerm_public_ip" "test" { | |
`, rInt, location, rInt) | ||
} | ||
|
||
func testAccAzureRMPublicIPStatic_basic_withZone(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_public_ip" "test" { | ||
name = "acctestpublicip-%d" | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. minor could we make the spacing consistent here? |
||
} | ||
`, rInt, location, rInt) | ||
} | ||
|
||
func testAccAzureRMPublicIPStatic_standard(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
|
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?