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

Adds managed attribute to azurestack_availability_set #104

Merged
merged 2 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions azurestack/resource_arm_availability_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package azurestack
import (
"fmt"
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/compute/mgmt/compute"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -47,13 +48,12 @@ func resourceArmAvailabilitySet() *schema.Resource {
ValidateFunc: validation.IntBetween(1, 3),
},

// Not supported for 2017-03-09 profile
// "managed": {
// Type: schema.TypeBool,
// Optional: true,
// Default: false,
// ForceNew: true,
// },
"managed": {
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},

"tags": tagsSchema(),
},
Expand All @@ -72,8 +72,7 @@ func resourceArmAvailabilitySetCreate(d *schema.ResourceData, meta interface{})
updateDomainCount := d.Get("platform_update_domain_count").(int)
faultDomainCount := d.Get("platform_fault_domain_count").(int)

// Not supported for 2017-03-09 profile
// managed := d.Get("managed").(bool)
managed := d.Get("managed").(bool)

tags := d.Get("tags").(map[string]interface{})

Expand All @@ -87,13 +86,12 @@ func resourceArmAvailabilitySetCreate(d *schema.ResourceData, meta interface{})
Tags: *expandTags(tags),
}

// Not supported for 2017-03-09 profile
// if managed == true {
// n := "Aligned"
// availSet.Sku = &compute.Sku{
// Name: &n,
// }
// }
if managed {
n := "Aligned"
availSet.Sku = &compute.Sku{
Name: &n,
}
}

resp, err := client.CreateOrUpdate(ctx, resGroup, name, availSet)
if err != nil {
Expand Down Expand Up @@ -134,10 +132,9 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er
d.Set("platform_update_domain_count", availSet.PlatformUpdateDomainCount)
d.Set("platform_fault_domain_count", availSet.PlatformFaultDomainCount)

// Not supported for 2017-03-09 profile
// if resp.Sku != nil && resp.Sku.Name != nil {
// d.Set("managed", strings.EqualFold(*resp.Sku.Name, "Aligned"))
// }
if resp.Sku != nil && resp.Sku.Name != nil {
d.Set("managed", strings.EqualFold(*resp.Sku.Name, "Aligned"))
}

flattenAndSetTags(d, &resp.Tags)

Expand Down
3 changes: 0 additions & 3 deletions azurestack/resource_arm_availability_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,8 @@ func TestAccAzureStackAvailabilitySet_withDomainCounts(t *testing.T) {
})
}

// managed not supported in the profile, skipping
func TestAccAzureStackAvailabilitySet_managed(t *testing.T) {

t.Skip()

resourceName := "azurestack_availability_set.test"
ri := acctest.RandInt()
config := testAccAzureStackAvailabilitySet_managed(ri, testLocation())
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/availability_set.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ The following arguments are supported:

~> **NOTE:** The number of Fault Domains varies depending on which Azure Region you're using - [a list can be found here](https://github.com/MicrosoftDocs/azure-docs/blob/master/includes/managed-disks-common-fault-domain-region-list.md).

* `managed` - (Optional) Specifies whether the availability set is managed or not. Possible values are `true` (to specify aligned) or `false` (to specify classic). Default is `false`.

* `tags` - (Optional) A mapping of tags to assign to the resource.

## Attributes Reference
Expand Down