Reputation: 2735
I am using aws-sdk gem
. i want to stop and start aws instance using 'aws-sdk' gem.
Below is my code to start an already stooped amazon instance but it is giving me error as SocketError: getaddrinfo: Name or service not known
ec2 = AWS::EC2::Client.new(
region: 'us-west-2c',
credentials: {:access_key_id => 'XXXXXXXXX',:secret_access_key => 'XXXXXXXXXXX'}
)
resp = ec2.start_instances({
instance_ids: ["i-xxxxxx"],
additional_info: "String"
})
Please help
Thanks,
Upvotes: 3
Views: 2383
Reputation: 2735
After a lot of research i came to know that i was specifying wrong region.
My region was 'us-west-2' and i was using region as 'us-west-2c' Which was not a region but availability zone.
After changing region to 'us-west-2' it works
AWS.config(
region: 'us-west-2',
access_key_id: 'xxxxxx',
secret_access_key: 'xxxxxxxxx'
)
ec2 = AWS::EC2::Client.new
resp = ec2.start_instances({
instance_ids: ["i-xxxxxxxxx"],
additional_info: "String"
})
Upvotes: 4