Skip to content

Commit

Permalink
Add 'Context' as an optional parameter for Auto Scaling 'CreateAutoSc…
Browse files Browse the repository at this point in the history
…alingGroup'
  • Loading branch information
gjmveloso committed May 23, 2022
1 parent 05781ea commit be203dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/service/autoscaling/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ func ResourceGroup() *schema.Resource {
ExactlyOneOf: []string{"launch_configuration", "launch_template", "mixed_instances_policy"},
},

"context": {
Type: schema.TypeString,
Optional: true,
},

"capacity_rebalance": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -732,6 +737,10 @@ func resourceGroupCreate(d *schema.ResourceData, meta interface{}) error {
createOpts.Tags = Tags(KeyValueTags(v, asgName, TagResourceTypeGroup).IgnoreAWS())
}

if v, ok := d.GetOk("context"); ok {
createOpts.Context = aws.String(v.(string))
}

if v, ok := d.GetOk("capacity_rebalance"); ok {
createOpts.CapacityRebalance = aws.Bool(v.(bool))
}
Expand Down Expand Up @@ -874,6 +883,7 @@ func resourceGroupRead(d *schema.ResourceData, meta interface{}) error {
}

d.Set("arn", g.AutoScalingGroupARN)
d.Set("context", g.Context)
d.Set("capacity_rebalance", g.CapacityRebalance)
d.Set("default_cooldown", g.DefaultCooldown)
d.Set("desired_capacity", g.DesiredCapacity)
Expand Down Expand Up @@ -1062,6 +1072,10 @@ func resourceGroupUpdate(d *schema.ResourceData, meta interface{}) error {
opts.DefaultCooldown = aws.Int64(int64(d.Get("default_cooldown").(int)))
}

if d.HasChange("context") {
opts.Context = aws.String(d.Get("context").(string))
}

if d.HasChange("capacity_rebalance") {
// If the capacity rebalance field is set to null, we need to explicitly set
// it back to "false", or the API won't reset it for us.
Expand Down
1 change: 1 addition & 0 deletions internal/service/autoscaling/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestAccAutoScalingGroup_basic(t *testing.T) {
resource.TestCheckResourceAttr("aws_autoscaling_group.bar", "min_size", "2"),
resource.TestCheckResourceAttr("aws_autoscaling_group.bar", "mixed_instances_policy.#", "0"),
resource.TestCheckResourceAttr("aws_autoscaling_group.bar", "name", randName),
resource.TestCheckResourceAttr("aws_autoscaling_group.bar", "context", ""),
resource.TestCheckResourceAttr("aws_autoscaling_group.bar", "placement_group", ""),
resource.TestCheckResourceAttr("aws_autoscaling_group.bar", "protect_from_scale_in", "false"),
acctest.CheckResourceAttrGlobalARN("aws_autoscaling_group.bar", "service_linked_role_arn", "iam", "role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/autoscaling_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ The following arguments are supported:
* `min_size` - (Required) The minimum size of the Auto Scaling Group.
(See also [Waiting for Capacity](#waiting-for-capacity) below.)
* `availability_zones` - (Optional) A list of one or more availability zones for the group. Used for EC2-Classic, attaching a network interface via id from a launch template and default subnets when not specified with `vpc_zone_identifier` argument. Conflicts with `vpc_zone_identifier`.
* `context` - (Optional) Reserved.
* `capacity_rebalance` - (Optional) Indicates whether capacity rebalance is enabled. Otherwise, capacity rebalance is disabled.
* `default_cooldown` - (Optional) The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.
* `launch_configuration` - (Optional) The name of the launch configuration to use.
Expand Down

0 comments on commit be203dc

Please sign in to comment.