Skip to content

Commit 554245d

Browse files
diehlawsjasdel
authored andcommitted
aws/ec2metadata: Add marketplaceProductCodes to Instance Identity Document (#374)
Adds MarketplaceProductCodes to the EC2 Instance Metadata's Identity Document. The ec2metadata client will now retrieve these values if they are available. Related to: aws/aws-sdk-go#2781
1 parent 68c6eba commit 554245d

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

CHANGELOG_PENDING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
* `private/protocol`: Add support for parsing fractional timestamp ([#367](https://github.com/aws/aws-sdk-go-v2/pull/367))
88
* Fixes the SDK's ability to parse fractional unix timestamp values and adds tests.
99
* Fixes [#365](https://github.com/aws/aws-sdk-go-v2/issues/365)
10+
* `aws/ec2metadata`: Add marketplaceProductCodes to EC2 Instance Identity Document
11+
* Adds `MarketplaceProductCodes` to the EC2 Instance Metadata's Identity Document. The ec2metadata client will now retrieve these values if they are available.
12+
* Related to: [aws/aws-sdk-go#2781](https://github.com/aws/aws-sdk-go/issues/2781)
1013

1114
### SDK Bugs
1215
* `aws`: Fixes bug in calculating throttled retry delay ([#373](https://github.com/aws/aws-sdk-go/pull/373))
1316
* The `Retry-After` duration specified in the request is now added to the Retry delay for throttled exception. Adds test for retry delays for throttled exceptions. Fixes bug where the throttled retry's math was off.
1417
* Fixes [#45](https://github.com/aws/aws-sdk-go/issues/45)
15-
18+

aws/ec2metadata/api_ops.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,21 @@ type EC2IAMInfo struct {
145145
// An EC2InstanceIdentityDocument provides the shape for unmarshaling
146146
// an instance identity document
147147
type EC2InstanceIdentityDocument struct {
148-
DevpayProductCodes []string `json:"devpayProductCodes"`
149-
AvailabilityZone string `json:"availabilityZone"`
150-
PrivateIP string `json:"privateIp"`
151-
Version string `json:"version"`
152-
Region string `json:"region"`
153-
InstanceID string `json:"instanceId"`
154-
BillingProducts []string `json:"billingProducts"`
155-
InstanceType string `json:"instanceType"`
156-
AccountID string `json:"accountId"`
157-
PendingTime time.Time `json:"pendingTime"`
158-
ImageID string `json:"imageId"`
159-
KernelID string `json:"kernelId"`
160-
RamdiskID string `json:"ramdiskId"`
161-
Architecture string `json:"architecture"`
148+
DevpayProductCodes []string `json:"devpayProductCodes"`
149+
MarketplaceProductCodes []string `json:"marketplaceProductCodes"`
150+
AvailabilityZone string `json:"availabilityZone"`
151+
PrivateIP string `json:"privateIp"`
152+
Version string `json:"version"`
153+
Region string `json:"region"`
154+
InstanceID string `json:"instanceId"`
155+
BillingProducts []string `json:"billingProducts"`
156+
InstanceType string `json:"instanceType"`
157+
AccountID string `json:"accountId"`
158+
PendingTime time.Time `json:"pendingTime"`
159+
ImageID string `json:"imageId"`
160+
KernelID string `json:"kernelId"`
161+
RamdiskID string `json:"ramdiskId"`
162+
Architecture string `json:"architecture"`
162163
}
163164

164165
func suffixPath(base, add string) string {

aws/ec2metadata/api_ops_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io/ioutil"
88
"net/http"
99
"net/http/httptest"
10+
"reflect"
1011
"strings"
1112
"testing"
1213

@@ -19,6 +20,7 @@ import (
1920

2021
const instanceIdentityDocument = `{
2122
"devpayProductCodes" : null,
23+
"marketplaceProductCodes" : [ "1abc2defghijklm3nopqrs4tu" ],
2224
"availabilityZone" : "us-east-1d",
2325
"privateIp" : "10.158.112.84",
2426
"version" : "2010-08-31",
@@ -338,4 +340,8 @@ func TestEC2RoleProviderInstanceIdentity(t *testing.T) {
338340
if e, a := doc.Region, "us-east-1"; e != a {
339341
t.Errorf("expect %v, got %v", e, a)
340342
}
343+
expectProductCodes := []string{"1abc2defghijklm3nopqrs4tu"}
344+
if e, a := expectProductCodes, doc.MarketplaceProductCodes; !reflect.DeepEqual(e, a) {
345+
t.Errorf("Expect %v product codes, got %v", e, a)
346+
}
341347
}

0 commit comments

Comments
 (0)