Skip to content

Commit

Permalink
resource/alicloud_ess_scaling_configuration: add system_disk_categories
Browse files Browse the repository at this point in the history
  • Loading branch information
fuliu-zln committed Jul 2, 2024
1 parent ad65b52 commit 0578211
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 93 deletions.
46 changes: 42 additions & 4 deletions alicloud/resource_alicloud_ess_scaling_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,20 @@ func resourceAlicloudEssScalingConfiguration() *schema.Resource {
}, false),
},
"system_disk_category": {
Type: schema.TypeString,
Optional: true,
Default: DiskCloudEfficiency,
ValidateFunc: StringInSlice([]string{"cloud", "ephemeral_ssd", "cloud_ssd", "cloud_essd", "cloud_efficiency"}, false),
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"cloud", "ephemeral_ssd", "cloud_ssd", "cloud_essd", "cloud_efficiency"}, false),
ConflictsWith: []string{"system_disk_categories"},
},
"system_disk_categories": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
MinItems: 1,
MaxItems: 4,
ConflictsWith: []string{"system_disk_category"},
},
"system_disk_size": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -472,6 +482,14 @@ func resourceAliyunEssScalingConfigurationCreate(d *schema.ResourceData, meta in
request["SystemDisk.Category"] = d.Get("system_disk_category")
}

if v, ok := d.GetOk("system_disk_categories"); ok {
count := 1
for _, value := range v.(*schema.Set).List() {
request[fmt.Sprintf("SystemDiskCategories.%d", count)] = value
count++
}
}

if v := d.Get("internet_max_bandwidth_in").(int); v != 0 {
request["InternetMaxBandwidthIn"] = d.Get("internet_max_bandwidth_in")
}
Expand Down Expand Up @@ -732,6 +750,17 @@ func modifyEssScalingConfiguration(d *schema.ResourceData, meta interface{}) err
update = true
}

if d.HasChange("system_disk_categories") {
if v, ok := d.GetOk("system_disk_categories"); ok {
count := 1
for _, value := range v.(*schema.Set).List() {
request[fmt.Sprintf("SystemDiskCategories.%d", count)] = value
count++
}
}
update = true
}

if d.HasChange("internet_max_bandwidth_out") {
request["InternetMaxBandwidthOut"] = d.Get("internet_max_bandwidth_out")
update = true
Expand Down Expand Up @@ -1065,12 +1094,21 @@ func resourceAliyunEssScalingConfigurationRead(d *schema.ResourceData, meta inte
return WrapError(err)
}

var systemDiskCategories []string
if response["SystemDiskCategories"] != nil && len(response["SystemDiskCategories"].(map[string]interface{})["SystemDiskCategory"].([]interface{})) > 0 {
for _, v := range response["SystemDiskCategories"].(map[string]interface{})["SystemDiskCategory"].([]interface{}) {
systemDiskCategories = append(systemDiskCategories, v.(string))
}
}

d.Set("scaling_group_id", response["ScalingGroupId"])
d.Set("image_id", response["ImageId"])
d.Set("image_name", response["ImageName"])
d.Set("scaling_configuration_name", response["ScalingConfigurationName"])
d.Set("internet_charge_type", response["InternetChargeType"])
d.Set("system_disk_category", response["SystemDiskCategory"])
d.Set("system_disk_categories", systemDiskCategories)

d.Set("internet_max_bandwidth_in", response["InternetMaxBandwidthIn"])
d.Set("internet_max_bandwidth_out", response["InternetMaxBandwidthOut"])

Expand Down
Loading

0 comments on commit 0578211

Please sign in to comment.