How can I get the Image ID after importing a disk image?

0

Hello,

I am writing a program that imports a disk image in my S3 bucket as an AMI, and then creates an EC2 instance with that AMI.
I succeeded in using the AWS SDK for Java to do each task separately, but I struggle with going from the first step to the second step.
Specifically, I struggle with getting the Image ID of the AMI after the import task is complete. I need the Image ID of the AMI to make an EC2 instance. I was trying to use an ImportImageResult to get the information, but calling getImageID() would return null.

After sending an ImportImageRequest, I want to wait until the import is complete and the new AMI is available. Then, I want to get the Image ID of the new AMI. How can I do this programmatically, and is there a best way to do it?

emul8r
質問済み 3年前303ビュー
1回答
0

The trick is to regularly call DescribeImportImageTasks, find the specific task, call getStatus on it to see if it is "completed", and if not, wait a bit before calling DescribeImportImageTasks again, etc., until the task is finally complete. Then, calling getImageID on that task would not return null. In order to make the task findable, I gave it a specific description, but I suppose giving it a specific tag could also work.

emul8r
回答済み 3年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ