How to get the ami id in AWS SDK for Ruby

Asked 2 years ago, Updated 2 years ago, 43 views

I want to get an ami id from AWS SDK for Ruby

AWS SDK for Ruby V2
Please use this as a reference.

require 'aws-sdk'
   ec2=Aws::EC2::Resource.new(region: 'ap-northeast-1')

  ec2.images.each do|i|
    puts "ID:#{i.image}"
  end

I've set up a program called , but when I run it, it doesn't show anything and I'm in trouble.
I would appreciate it if you could help me.
Thank you for your cooperation.

ami has already been created.
SDK works.

ruby 2.3.3
AWS SDK for Ruby V2
ubuntu 18.04

ruby aws

2022-09-30 19:47

3 Answers

Does the document say image_id instead of image

?


2022-09-30 19:47

How about checking the contents of i first?

ec2.images.each do|i|
  pi
end


2022-09-30 19:47

Is the image of that target created in the Tokyo region?Is it in a different region?


2022-09-30 19:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.