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

Allow setting of the EbsOptimized flag when provisioning instances #94

Merged
merged 2 commits into from
Sep 3, 2014
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
5 changes: 5 additions & 0 deletions ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ type RunInstances struct {
SubnetId string
AssociatePublicIpAddress bool
DisableAPITermination bool
EbsOptimized bool
ShutdownBehavior string
PrivateIPAddress string
BlockDevices []BlockDeviceMapping
Expand Down Expand Up @@ -296,6 +297,7 @@ type Instance struct {
LaunchTime time.Time `xml:"launchTime"`
SourceDestCheck bool `xml:"sourceDestCheck"`
SecurityGroups []SecurityGroup `xml:"groupSet>item"`
EbsOptimized string `xml:"ebsOptimized"`
}

// RunInstances starts new instances in EC2.
Expand Down Expand Up @@ -392,6 +394,9 @@ func (ec2 *EC2) RunInstances(options *RunInstances) (resp *RunInstancesResp, err
if options.DisableAPITermination {
params["DisableApiTermination"] = "true"
}
if options.EbsOptimized {
params["EbsOptimized"] = "true"
}
if options.ShutdownBehavior != "" {
params["InstanceInitiatedShutdownBehavior"] = options.ShutdownBehavior
}
Expand Down
3 changes: 3 additions & 0 deletions ec2/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (s *S) TestRunInstancesExample(c *C) {
Monitoring: true,
SubnetId: "subnet-id",
DisableAPITermination: true,
EbsOptimized: true,
ShutdownBehavior: "terminate",
PrivateIPAddress: "10.0.0.25",
BlockDevices: []ec2.BlockDeviceMapping{
Expand Down Expand Up @@ -168,6 +169,7 @@ func (s *S) TestRunInstancesExample(c *C) {
c.Assert(req.Form["Monitoring.Enabled"], DeepEquals, []string{"true"})
c.Assert(req.Form["SubnetId"], DeepEquals, []string{"subnet-id"})
c.Assert(req.Form["DisableApiTermination"], DeepEquals, []string{"true"})
c.Assert(req.Form["EbsOptimized"], DeepEquals, []string{"true"})
c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], DeepEquals, []string{"terminate"})
c.Assert(req.Form["PrivateIpAddress"], DeepEquals, []string{"10.0.0.25"})
c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
Expand Down Expand Up @@ -304,6 +306,7 @@ func (s *S) TestTerminateInstancesExample(c *C) {
c.Assert(req.Form["Monitoring.Enabled"], IsNil)
c.Assert(req.Form["SubnetId"], IsNil)
c.Assert(req.Form["DisableApiTermination"], IsNil)
c.Assert(req.Form["EbsOptimized"], IsNil)
c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], IsNil)
c.Assert(req.Form["PrivateIpAddress"], IsNil)

Expand Down