From f47083748dd777db62561f7e0685219dfc438ec1 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Sat, 29 Mar 2014 12:11:39 +0000 Subject: [PATCH 1/6] Bump EC2 api version to latest to support network interfaces and associating public IPs --- ec2/ec2.go | 2 +- ec2/ec2_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ec2/ec2.go b/ec2/ec2.go index 3cbb1a3..a46d111 100644 --- a/ec2/ec2.go +++ b/ec2/ec2.go @@ -119,7 +119,7 @@ type xmlErrors struct { var timeNow = time.Now func (ec2 *EC2) query(params map[string]string, resp interface{}) error { - params["Version"] = "2013-02-01" + params["Version"] = "2014-02-01" params["Timestamp"] = timeNow().In(time.UTC).Format(time.RFC3339) endpoint, err := url.Parse(ec2.Region.EC2Endpoint) if err != nil { diff --git a/ec2/ec2_test.go b/ec2/ec2_test.go index 4a7fd8b..3decae8 100644 --- a/ec2/ec2_test.go +++ b/ec2/ec2_test.go @@ -833,5 +833,5 @@ func (s *S) TestSignatureWithEndpointPath(c *gocheck.C) { c.Assert(err, gocheck.IsNil) req := testServer.WaitRequest() - c.Assert(req.Form["Signature"], gocheck.DeepEquals, []string{"klxs+VwDa1EKHBsxlDYYN58wbP6An+RVdhETv1Fm/os="}) + c.Assert(req.Form["Signature"], gocheck.DeepEquals, []string{"VVoC6Y6xfES+KvZo+789thP8+tye4F6fOKBiKmXk4S4="}) } From 7348677045d3badc3b333199bcdd05676d4e8fb9 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Sat, 29 Mar 2014 12:14:54 +0000 Subject: [PATCH 2/6] Specify IamInstanceProfile as a type on run instances options --- ec2/ec2.go | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/ec2/ec2.go b/ec2/ec2.go index a46d111..c048b48 100644 --- a/ec2/ec2.go +++ b/ec2/ec2.go @@ -193,25 +193,24 @@ func addParamsList(params map[string]string, label string, ids []string) { // // See http://goo.gl/Mcm3b for more details. type RunInstancesOptions struct { - ImageId string - MinCount int - MaxCount int - KeyName string - InstanceType string - SecurityGroups []SecurityGroup - KernelId string - RamdiskId string - UserData []byte - AvailabilityZone string - PlacementGroupName string - Monitoring bool - SubnetId string - DisableAPITermination bool - ShutdownBehavior string - PrivateIPAddress string - IamInstanceProfileArn string - IamInstanceProfileName string - BlockDeviceMappings []BlockDeviceMapping + ImageId string + MinCount int + MaxCount int + KeyName string + InstanceType string + SecurityGroups []SecurityGroup + KernelId string + RamdiskId string + UserData []byte + AvailabilityZone string + PlacementGroupName string + Monitoring bool + SubnetId string + DisableAPITermination bool + ShutdownBehavior string + PrivateIPAddress string + IamInstanceProfile IamInstanceProfile + BlockDeviceMappings []BlockDeviceMapping } // Response to a RunInstances request. @@ -357,8 +356,9 @@ type InstancePrivateIpAddress struct { // IamInstanceProfile // See http://goo.gl/PjyijL for more details type IamInstanceProfile struct { - ARN string `xml:"arn"` - Id string `xml:"id"` + ARN string `xml:"arn"` + Id string `xml:"id"` + Name string `xml:"name"` } // RunInstances starts new instances in EC2. @@ -460,11 +460,11 @@ func (ec2 *EC2) RunInstances(options *RunInstancesOptions) (resp *RunInstancesRe if options.PrivateIPAddress != "" { params["PrivateIpAddress"] = options.PrivateIPAddress } - if options.IamInstanceProfileArn != "" { - params["IamInstanceProfile.Arn"] = options.IamInstanceProfileArn + if options.IamInstanceProfile.ARN != "" { + params["IamInstanceProfile.Arn"] = options.IamInstanceProfile.ARN } - if options.IamInstanceProfileName != "" { - params["IamInstanceProfile.Name"] = options.IamInstanceProfileName + if options.IamInstanceProfile.Name != "" { + params["IamInstanceProfile.Name"] = options.IamInstanceProfile.Name } resp = &RunInstancesResp{} From 821701426729c8327f643fc165eb4c3e3a98001d Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Sat, 29 Mar 2014 12:23:46 +0000 Subject: [PATCH 3/6] Add placement tenancy on RunInstances --- ec2/ec2.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ec2/ec2.go b/ec2/ec2.go index c048b48..47dded5 100644 --- a/ec2/ec2.go +++ b/ec2/ec2.go @@ -204,6 +204,7 @@ type RunInstancesOptions struct { UserData []byte AvailabilityZone string PlacementGroupName string + Tenancy string Monitoring bool SubnetId string DisableAPITermination bool @@ -445,6 +446,9 @@ func (ec2 *EC2) RunInstances(options *RunInstancesOptions) (resp *RunInstancesRe if options.PlacementGroupName != "" { params["Placement.GroupName"] = options.PlacementGroupName } + if options.Tenancy != "" { + params["Placement.Tenancy"] = options.Tenancy + } if options.Monitoring { params["Monitoring.Enabled"] = "true" } From 62781e8a06e80159ec59fd109d0eb23878af9145 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Sat, 29 Mar 2014 12:27:13 +0000 Subject: [PATCH 4/6] Allow EbsOptimized option to be set when running instances --- ec2/ec2.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ec2/ec2.go b/ec2/ec2.go index 47dded5..3a15b19 100644 --- a/ec2/ec2.go +++ b/ec2/ec2.go @@ -212,6 +212,7 @@ type RunInstancesOptions struct { PrivateIPAddress string IamInstanceProfile IamInstanceProfile BlockDeviceMappings []BlockDeviceMapping + EbsOptimized bool } // Response to a RunInstances request. @@ -470,6 +471,9 @@ func (ec2 *EC2) RunInstances(options *RunInstancesOptions) (resp *RunInstancesRe if options.IamInstanceProfile.Name != "" { params["IamInstanceProfile.Name"] = options.IamInstanceProfile.Name } + if options.EbsOptimized { + params["EbsOptimized"] = "true" + } resp = &RunInstancesResp{} err = ec2.query(params, resp) From 17e613af00bc12e71a6f56067a25fe4a08d83fc3 Mon Sep 17 00:00:00 2001 From: Brian Hong Date: Mon, 31 Mar 2014 10:45:11 +0900 Subject: [PATCH 5/6] Fix elb DescribeInstanceHealth not working with multiple instances --- elb/elb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elb/elb.go b/elb/elb.go index efbaaff..89c1b18 100644 --- a/elb/elb.go +++ b/elb/elb.go @@ -233,8 +233,8 @@ func (elb *ELB) DescribeInstanceHealth(lbName string, instanceIds ...string) (*D "Action": "DescribeInstanceHealth", "LoadBalancerName": lbName, } - for _, iId := range instanceIds { - key := fmt.Sprintf("Instances.member.1.InstanceId") + for i, iId := range instanceIds { + key := fmt.Sprintf("Instances.member.%d.InstanceId", i + 1) params[key] = iId } resp := new(DescribeInstanceHealthResp) From 52b5cd9d069a64c0f2cca567e86da2e50e42123a Mon Sep 17 00:00:00 2001 From: Brian Hong Date: Mon, 31 Mar 2014 14:26:30 +0900 Subject: [PATCH 6/6] Fix gofmt in elb.go --- elb/elb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elb/elb.go b/elb/elb.go index 89c1b18..218d047 100644 --- a/elb/elb.go +++ b/elb/elb.go @@ -234,7 +234,7 @@ func (elb *ELB) DescribeInstanceHealth(lbName string, instanceIds ...string) (*D "LoadBalancerName": lbName, } for i, iId := range instanceIds { - key := fmt.Sprintf("Instances.member.%d.InstanceId", i + 1) + key := fmt.Sprintf("Instances.member.%d.InstanceId", i+1) params[key] = iId } resp := new(DescribeInstanceHealthResp)