Aws-sdk gem: SocketError: getaddrinfo: name or service unknown

I am using aws-sdk gem

. I want to stop and start an aws instance using the "aws-sdk" harness.

Below is my code to start an already slouching amazon instance but it gives me error like 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

Thank,

+3


source to share


1 answer


After a lot of research, I found out that I am specifying the wrong region.

My region was "us-west-2" and I used the region as "us-west-2c". It was not a region, but an accessibility zone.



After changing the area 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"
})

      

+4


source







All Articles