Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';更新包后,无法使用Ruby AWS SDK获取实例标记_Ruby_Amazon Web Services_Amazon Ec2_Sdk - Fatal编程技术网

Can';更新包后,无法使用Ruby AWS SDK获取实例标记

Can';更新包后,无法使用Ruby AWS SDK获取实例标记,ruby,amazon-web-services,amazon-ec2,sdk,Ruby,Amazon Web Services,Amazon Ec2,Sdk,我在启动时使用Ruby AWS SDK运行一个脚本。它以前工作正常,但在使用yum update更新实例后,当它在启动时运行时,我会得到空的instance.tags,但是当我手动运行它时,它工作正常。脚本如下所示: require 'rubygems' require 'aws-sdk' ec2 = AWS::EC2.new my_instance_id = ENV['AWS_INSTANCE'] warn "this instance: #{my_instance_id}" # pro

我在启动时使用Ruby AWS SDK运行一个脚本。它以前工作正常,但在使用
yum update
更新实例后,当它在启动时运行时,我会得到空的
instance.tags
,但是当我手动运行它时,它工作正常。脚本如下所示:

require 'rubygems'
require 'aws-sdk'

ec2 = AWS::EC2.new

my_instance_id = ENV['AWS_INSTANCE']

warn "this instance: #{my_instance_id}" # proper output here

instance = ec2.instances[my_instance_id]

asg_name = instance.tags["aws:autoscaling:groupName"] # nil here! instance.tags are empty

由于我得到了
AWS::Errors::MissingCredentialsError
AWS::EC2::Errors::AuthFailure
,因此凭据没有丢失或错误。为什么我不能得到实例标签呢?

ec2.instances提供了什么?你能发布吗?@Surya,好的,我会在几分钟后发布实例restarts@Surya,实际上,如何将其打印为散列?什么意思?如何打印为散列?只需将其作为输出发布:
ec2.instances 35;=>{key::value}
@Surya,
#