Sha256: 72c4a9de140638a6de9a094d3202d4e051d8edd4ec58a43760f3570c25b8f15d
Contents?: true
Size: 798 Bytes
Versions: 39
Compression:
Stored size: 798 Bytes
Contents
# frozen_string_literal: true module Facter module Util module Resolvers module AwsToken attr_reader :token @log = Facter::Log.new(self) class << self AWS_API_TOKEN_URL = 'http://169.254.169.254/latest/api/token' def get(lifetime = 100) @expiry ||= Time.now return @token if @token && @expiry > Time.now @token = nil @expiry = Time.now + lifetime headers = { 'X-aws-ec2-metadata-token-ttl-seconds' => lifetime.to_s } @token = Facter::Util::Resolvers::Http.put_request(AWS_API_TOKEN_URL, headers) end def reset @expiry = nil @token = nil end end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems