Skip to content

EC2 describevolumes is not working #84

@johnny-guo

Description

@johnny-guo

Hi,

I'm trying to get volume id with the following code but always get "400" error (bad request):

ClientConfiguration config;
config.scheme = Scheme::HTTPS;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 30000;

auto client = Aws::MakeShared("Test", config);

Filter f1, f2;
f1.SetName("tag:Name"); f1.AddValues("TestData");
f2.SetName("attachment.instance-id"); f2.AddValues(getInstanceId());

DescribeVolumesRequest req;
req.AddFilters(f1);
req.AddFilters(f2);

DescribeVolumesOutcome out = client->DescribeVolumes(req);
if (out.IsSuccess())
{
Aws::Vector vols = out.GetResult().GetVolumes();
if (vols[0].GetState() != VolumeState::in_use)
{
LOGGER->Log("Volume is busy");
return std::string();
}

  return vols[0].GetVolumeId().c_str();

}
LOGGER->Log("DescribeVolumeRequest Error: %s", out.GetError().GetMessage().c_str());
return std::string();

Could someone please shed some light what I have been missing?

Thanks,
Johnny

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions