我在启动时使用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
后,凭据不会丢失或错误。为什么我不能获得实例标签呢?