Method: Instance::EC2#tag_instance_name

Defined in:
lib/maws/instance/ec2.rb

#tag_instance_nameObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/maws/instance/ec2.rb', line 46

def tag_instance_name
  retries_left = 20
  loop do
    begin
      connection.ec2.create_tags(aws_id, {'Name' => name})
      info "tagged EC2 instance #{aws_id} as #{name}"
      return
    rescue RightAws::AwsError => error
      if error.message =~ /^InvalidInstanceID.NotFound/
        info "TAGGING FAILED. RETRYING..."
      else
        raise error
      end
    end

    retries_left -= 1
    retries_left > 0 ? sleep(1) : break
  end
  error "Couldn't not tag #{aws_id} with name #{name}. It might not exist on AWS"
end