aws-doc-sdk-examples icon indicating copy to clipboard operation
aws-doc-sdk-examples copied to clipboard

Method used to get InstanceID in CreateInstance.java example is incorrect

Open psuri opened this issue 8 years ago • 3 comments

While trying to play around with the example(CreateInstance.java) snippets, I noticed that below is used to get instanceID:-

String instance_id = run_response.getReservation().getReservationId();

This is incorrect, as this gives the reservation ID of the format "r-" and correct way to get Instance ID is actually this:-

run_response.getReservation().getInstances();

psuri avatar Jan 23 '18 20:01 psuri

Provided solution by psuri seems to not work anymore. It seems that this code does not give instance ID but reservation ID. I was able to get instance ID using this:

String instance_id = response.instances().get(0).instanceId();

However there are still issues with creating TAG

The request must contain the parameter resourceIdSet (Service: Ec2, Status Code: 400, Request ID: 224a76bc-7da9-4639-b2df-63f0d0ec7764)

EwelinaH avatar Jan 03 '19 22:01 EwelinaH

Tagging problem also solved.

    CreateTagsRequest tag_request = CreateTagsRequest.builder()
            .resources(instance_id)
            .tags(tag)
            .build();

EwelinaH avatar Jan 03 '19 22:01 EwelinaH

Sample has been updated.

jschwarzwalder avatar Jan 15 '19 16:01 jschwarzwalder