diff --git a/lib/facter/resolvers/az.rb b/lib/facter/resolvers/az.rb index 0f558ccb2c..535749c768 100644 --- a/lib/facter/resolvers/az.rb +++ b/lib/facter/resolvers/az.rb @@ -26,6 +26,7 @@ def read_facts(fact_name) def get_data_from(url) headers = { Metadata: 'true' } + headers['X-aws-ec2-metadata-token'] = v2_token if v2_token Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout }) end @@ -33,6 +34,13 @@ def determine_session_timeout session_env = ENV['AZ_SESSION_TIMEOUT'] session_env ? session_env.to_i : AZ_SESSION_TIMEOUT end + + def v2_token + @v2_token ||= begin + token = Facter::Util::Resolvers::AwsToken.get + token == '' ? nil : token + end + end end end end