Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

adds TerminateInstanceInAutoScalingGroup #150

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions autoscaling/autoscaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,28 @@ func (autoscaling *AutoScaling) UpdateAutoScalingGroup(options *UpdateAutoScalin
return
}

func (autoscaling *AutoScaling) TerminateInstanceInAutoScalingGroup(instance string, decrementCapacity bool) (resp *SimpleResp, err error) {
resp = &SimpleResp{}
err = nil

params := makeParams("TerminateInstanceInAutoScalingGroup")

params["InstanceId"] = instance

if decrementCapacity {
params["ShouldDecrementDesiredCapacity"] = "true"
} else {
params["ShouldDecrementDesiredCapacity"] = "false"
}

err = autoscaling.query(params, resp)
if err != nil {
resp = nil
}

return
}

// Responses

type SimpleResp struct {
Expand Down
11 changes: 11 additions & 0 deletions autoscaling/autoscaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,14 @@ func (s *S) Test_UpdateAutoScalingGroup(c *C) {
c.Assert(err, IsNil)
c.Assert(resp.RequestId, Equals, "adafead0-ab8a-11e2-ba13-ab0ccEXAMPLE")
}

func (s *S) Test_TerminateInstanceInAutoScalingGroup(c *C) {
testServer.Response(200, nil, TerminateInstanceInAutoScalingGroup)

resp, err := s.autoscaling.TerminateInstanceInAutoScalingGroup("i-123456", true)
req := testServer.WaitRequest()

c.Assert(req.Form["Action"], DeepEquals, []string{"TerminateInstanceInAutoScalingGroup"})
c.Assert(err, IsNil)
c.Assert(resp.RequestId, Equals, "adafead0-ab8a-11e2-ba13-ab0ccEXAMPLE")
}
9 changes: 9 additions & 0 deletions autoscaling/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,12 @@ var UpdateAutoScalingGroupExample = `
</ResponseMetadata>
</UpdateAutoScalingGroupResponse>
`

var TerminateInstanceInAutoScalingGroup = `
<TerminateInstanceInAutoScalingGroupResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
<ResponseMetadata>
<RequestId>adafead0-ab8a-11e2-ba13-ab0ccEXAMPLE</RequestId>
</ResponseMetadata>
</TerminateInstanceInAutoScalingGroupResponse>

`