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

resource/alicloud_ess_scaling_group: add attributes of compensate_with_on_demand, capacity_options_on_demand_base_capacity, capacity_options_on_demand_percentage_above_base_capacity, capacity_options_compensate_with_on_demand and capacity_options_spot_auto_replace_on_demand. #8320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
85 changes: 85 additions & 0 deletions alicloud/resource_alicloud_ess_scaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,33 @@ func resourceAlicloudEssScalingGroup() *schema.Resource {
Optional: true,
Computed: true,
},
"compensate_with_on_demand": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"capacity_options_on_demand_base_capacity": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: IntBetween(0, 1000),
},
"capacity_options_on_demand_percentage_above_base_capacity": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: IntBetween(0, 100),
},
"capacity_options_compensate_with_on_demand": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"capacity_options_spot_auto_replace_on_demand": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"resource_group_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -331,7 +358,9 @@ func resourceAliyunEssScalingGroupRead(d *schema.ResourceData, meta interface{})
if object["SpotInstancePools"] != nil {
d.Set("spot_instance_pools", object["SpotInstancePools"])
}

d.Set("spot_instance_remedy", object["SpotInstanceRemedy"])
d.Set("compensate_with_on_demand", object["CompensateWithOnDemand"])
d.Set("group_deletion_protection", object["GroupDeletionProtection"])
var polices []string
if len(object["RemovalPolicies"].(map[string]interface{})["RemovalPolicy"].([]interface{})) > 0 {
Expand Down Expand Up @@ -393,6 +422,22 @@ func resourceAliyunEssScalingGroupRead(d *schema.ResourceData, meta interface{})
}
}

if v := object["CapacityOptions"]; v != nil {
m := v.(map[string]interface{})
if m["OnDemandBaseCapacity"] != nil {
d.Set("capacity_options_on_demand_base_capacity", m["OnDemandBaseCapacity"])
}
if m["OnDemandPercentageAboveBaseCapacity"] != nil {
d.Set("capacity_options_on_demand_percentage_above_base_capacity", m["OnDemandPercentageAboveBaseCapacity"])
}
if m["CompensateWithOnDemand"] != nil {
d.Set("capacity_options_compensate_with_on_demand", m["CompensateWithOnDemand"])
}
if m["SpotAutoReplaceOnDemand"] != nil {
d.Set("capacity_options_spot_auto_replace_on_demand", m["SpotAutoReplaceOnDemand"])
}
}

if v := object["AlbServerGroups"]; v != nil {
result := make([]map[string]interface{}, 0)
if w, ok := d.GetOk("alb_server_group"); ok {
Expand Down Expand Up @@ -540,10 +585,30 @@ func resourceAliyunEssScalingGroupUpdate(d *schema.ResourceData, meta interface{
request["SpotInstancePools"] = requests.NewInteger(d.Get("spot_instance_pools").(int))
}

if d.HasChange("capacity_options_on_demand_base_capacity") {
request["CapacityOptions.OnDemandBaseCapacity"] = requests.NewInteger(d.Get("capacity_options_on_demand_base_capacity").(int))
}

if d.HasChange("capacity_options_on_demand_base_capacity") {
request["CapacityOptions.OnDemandBaseCapacity"] = requests.NewInteger(d.Get("capacity_options_on_demand_base_capacity").(int))
}

if d.HasChange("capacity_options_compensate_with_on_demand") {
request["CapacityOptions.CompensateWithOnDemand"] = requests.NewBoolean(d.Get("capacity_options_compensate_with_on_demand").(bool))
}

if d.HasChange("capacity_options_spot_auto_replace_on_demand") {
request["CapacityOptions.SpotAutoReplaceOnDemand"] = requests.NewBoolean(d.Get("capacity_options_spot_auto_replace_on_demand").(bool))
}

if d.HasChange("spot_instance_remedy") {
request["SpotInstanceRemedy"] = requests.NewBoolean(d.Get("spot_instance_remedy").(bool))
}

if d.HasChange("compensate_with_on_demand") {
request["CompensateWithOnDemand"] = requests.NewBoolean(d.Get("compensate_with_on_demand").(bool))
}

if d.HasChange("az_balance") {
request["AzBalance"] = requests.NewBoolean(d.Get("az_balance").(bool))
}
Expand Down Expand Up @@ -765,10 +830,30 @@ func buildAlicloudEssScalingGroupArgs(d *schema.ResourceData, meta interface{})
request["SpotInstancePools"] = v
}

if v, ok := d.GetOk("capacity_options_on_demand_base_capacity"); ok {
request["CapacityOptions.OnDemandBaseCapacity"] = v
}

if v, ok := d.GetOk("capacity_options_on_demand_base_capacity"); ok {
request["CapacityOptions.OnDemandBaseCapacity"] = v
}

if v, ok := d.GetOk("capacity_options_compensate_with_on_demand"); ok {
request["CapacityOptions.CompensateWithOnDemand"] = v
}

if v, ok := d.GetOk("capacity_options_spot_auto_replace_on_demand"); ok {
request["CapacityOptions.SpotAutoReplaceOnDemand"] = v
}

if v, ok := d.GetOk("spot_instance_remedy"); ok {
request["SpotInstanceRemedy"] = v
}

if v, ok := d.GetOk("compensate_with_on_demand"); ok {
request["CompensateWithOnDemand"] = v
}

if v, ok := d.GetOk("health_check_type"); ok {
request["HealthCheckType"] = v
}
Expand Down
Loading
Loading