Jira (FACT-3042) Facter should retrieve EC2 metadata using IMDSv2 without requring user configuration

28 views
Skip to first unread message

Charlie Sharpsteen (Jira)

unread,
May 17, 2021, 4:38:02 PM5/17/21
to puppe...@googlegroups.com
Charlie Sharpsteen created an issue
 
Facter / Improvement FACT-3042
Facter should retrieve EC2 metadata using IMDSv2 without requring user configuration
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2021/05/17 1:37 PM
Priority: Normal Normal
Reporter: Charlie Sharpsteen

FACT-2306 introduced support for v2 of the EC2 Instance Meta Data Service. However, this support has to be explicitly enabled by setting the AWS_IMDSv2 environment variable to true.

The environment variable requirement creates two points of friction:

  • Using an environment variable instead of an entry in the Facter configuration makes it easy to get differing behavior depending on execution context. The environment that the puppet service receives is configured with a different set of files from that of a user shell which leads to inconsistent behavior.
  • Requiring an environment variable makes AWS instances with HttpTokens=required special in that they require post-installation configuration that existing installation methods, like the puppet_agent module or PE install scripts, do not automate.

If possible, Facter should use IMDSv2 automatically when available. Otherwise, Facter should allow IMDSv2 to be controlled by a configuration setting.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Charlie Sharpsteen (Jira)

unread,
May 17, 2021, 4:38:04 PM5/17/21
to puppe...@googlegroups.com

Charlie Sharpsteen (Jira)

unread,
May 17, 2021, 4:43:02 PM5/17/21
to puppe...@googlegroups.com
Charlie Sharpsteen commented on Improvement FACT-3042
 
Re: Facter should retrieve EC2 metadata using IMDSv2 without requring user configuration

The AWS SDKs approach this situation by always using IMDSv2 and falling back to IMDSv1:

The AWS SDKs use IMDSv2 calls by default. If the IMDSv2 call receives no response, the SDK retries the call and, if still unsuccessful, uses IMDSv1.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html#imds-considerations

This is also the approach Ohai takes when gathering ec2_metadata by always including the X-aws-ec2-metadata-token header, even if empty:

https://github.com/chef/ohai/blob/v17.1.0/lib/ohai/mixin/ec2_metadata.rb#L121

Mihai Buzgau (Jira)

unread,
May 18, 2021, 10:32:01 AM5/18/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
May 18, 2021, 10:35:02 AM5/18/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
May 19, 2021, 5:01:04 AM5/19/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
May 20, 2021, 6:31:02 AM5/20/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Jun 16, 2021, 3:45:01 AM6/16/21
to puppe...@googlegroups.com

Christine Yoon (Jira)

unread,
Jun 21, 2021, 10:21:01 AM6/21/21
to puppe...@googlegroups.com

Christine Yoon (Jira)

unread,
Jun 21, 2021, 2:28:03 PM6/21/21
to puppe...@googlegroups.com

Christine Yoon (Jira)

unread,
Jun 21, 2021, 2:43:03 PM6/21/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages