DescribeHostReservations should return the list of Host Reservations the account has.
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))
Define, in the EC2 service models file, the locationName as item to the HostReservation member of HostReservationSet.
( Submitted Pull Request: #723 )
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);
}
}
}
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.
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.