阅读背景:

aws-sdk gem: SocketError: getaddrinfo:名称或服务未知

来源:互联网 

I am using aws-sdk gem. i want to stop and start aws instance using 'aws-sdk' gem.

我正在使用aws-sdk gem。我想使用“aws-sdk”gem停止并启动aws实例。

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

下面是我的代码来启动一个已经弯曲的amazon实例,但是它给我的错误是SocketError: getaddrinfo: Name或服务未知

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,

谢谢,

1 个解决方案

#1


4  

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.

我的区域是“us-west-2”,我使用区域作为“us-west-2c”,这不是一个区域,而是可用区域。

After changing region to 'us-west-2' it works

将区域转换为us-west-2之后,它就可以工作了

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"
})

分享到: