Aws-sdk-net: EC2.DescribeHostReservations() always returns an empty list

Created on 11 Aug 2017  Â·  7Comments  Â·  Source: aws/aws-sdk-net

Expected Behavior

DescribeHostReservations should return the list of Host Reservations the account has.

Current Behavior

Regardless of the parameters used on the request for DescribeHostReservations(), it always returns an empty list of reservations because the unmarshaller is parsing the resulting XML incorrectly.

Incoming XML structure:

<?xml version="1.0" encoding="UTF-8"?>
<DescribeHostReservationsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
    <requestId></requestId>
    <hostReservationSet>
        <item>
            <upfrontPrice></upfrontPrice>
            <count></count>
            <start></start>
            <instanceFamily></instanceFamily>
            <offeringId></offeringId>
            <duration></duration>
            <paymentOption></paymentOption>
            <end></end>
            <hostReservationId></hostReservationId>
            <state></state>
            <hourlyPrice></hourlyPrice>
            <hostIdSet>
                <item></item>
            </hostIdSet>
        </item>
    </hostReservationSet>
</DescribeHostReservationsResponse>

Each host reservation is listed as an item element inside hostReservationSet.

The resulting generated unmarshaller is trying to read items as member:

if (context.TestExpression("hostReservationSet/member", targetDepth))

Possible Solution

Define, in the EC2 service models file, the locationName as item to the HostReservation member of HostReservationSet.

( Submitted Pull Request: #723 )

Steps to Reproduce

Call DescribeHostReservations() for any account with Host Reservations, in a given region.
The list HostReservationSet will always be empty.

Snippet:

// Fill in your credentials
var accessKey = "AKIAXXXXXXXXXXXXXXXX";
var secretKey = "asdfasdfasdfasdfasdfasdfasdfasdfadfafasf";

var request = new AssumeRoleRequest();
request.ExternalId = "MY-EXTERNAL-ID";
request.RoleArn = "arn:aws:iam::000000000000:role/myrole";
request.RoleSessionName = "myrole";

var basicCredentials = new BasicAWSCredentials(accessKey, secretKey);
using (var securityTokenServiceClient = new AmazonSecurityTokenServiceClient(basicCredentials))
{
    var assumeRole = securityTokenServiceClient.AssumeRole(request);
    var sessionCredential = new SessionAWSCredentials(assumeRole.Credentials.AccessKeyId, assumeRole.Credentials.SecretAccessKey, assumeRole.Credentials.SessionToken);
    using (var client = new Amazon.EC2.AmazonEC2Client(sessionCredential, RegionEndpoint.USEast1))
    {
        var hrs = client.DescribeHostReservations(new Amazon.EC2.Model.DescribeHostReservationsRequest());

        // This always returns an empty list
        foreach (var item in hrs.HostReservationSet)
        {
            Console.WriteLine("{0}-{1}-{2}", item.HostReservationId, item.UpfrontPrice, item.InstanceFamily);
        }
    }
}

Environment

  • AWSSDK.Core version used: 3.3.17
  • Service assembly and version used: 3.3.13.6
  • Operating System and version: Windows 10 (Dev machine), Windows Server 2012 R2 (EC2 instance)
  • Visual Studio version: Visual Studio 2017, Version 15.2 (26430.16) Release
  • Targeted .NET platform: 4.5
bug service-api

Most helpful comment

EC2 team confirmed that this is an issue with the model and we'll have a release out to address this soon. Thanks again for reporting this.

All 7 comments

I need this feature working!

Thanks for reporting this. I was able to repro this and looking into it.

Hello! Just in case, there is a PR for this ticket:

https://github.com/aws/aws-sdk-net/pull/723

Thanks!

—
Waldo

El vie., 11 de ago. de 2017 a la(s) 15:34, Steven Kang <
[email protected]> escribió:

Thanks for reporting this. I was able to repro this and looking into it.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/aws/aws-sdk-net/issues/724#issuecomment-321887686,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVvGl9vTYxbuG7aKnovwwdBYoIxQ3dzTks5sXJ7IgaJpZM4O0jyq
.

Our team doesn't own the json models, so we can't take this PR. We are reaching out to EC2 team to resolve this.

EC2 team confirmed that this is an issue with the model and we'll have a release out to address this soon. Thanks again for reporting this.

This should be fixed by 072ff53ce567255. Updated nuget package is available: https://www.nuget.org/packages/AWSSDK.EC2/3.3.21

It looks like the EC2's model update is identical to the PR :)

Thank you, @sstevenkang.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShahriatHossain picture ShahriatHossain  Â·  4Comments

krzysztof-at-mp picture krzysztof-at-mp  Â·  4Comments

Lapeno94 picture Lapeno94  Â·  4Comments

imkheong picture imkheong  Â·  3Comments

haswalt picture haswalt  Â·  5Comments