Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] s3 module fails when IMDSv2 is enforced on ec2 instances #60668

Closed
ryanm-sq opened this issue Aug 3, 2021 · 7 comments
Closed

[BUG] s3 module fails when IMDSv2 is enforced on ec2 instances #60668

ryanm-sq opened this issue Aug 3, 2021 · 7 comments
Assignees
Labels
boto AWS wrapper modules Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around

Comments

@ryanm-sq
Copy link

ryanm-sq commented Aug 3, 2021

Description
An ec2 minion with IMDSv2 enabled cannot properly use it's IAM instance profile with the s3 module. The s3 module fails with the message Error running 's3.get': Failed s3 operation. InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.

Setup
Enforce IMDSv2 on a standalone minion running in AWS EC2:

$ aws ec2 modify-instance-metadata-options --instance-id {INSTANCE_ID} --http-tokens required --http-endpoint enabled

Steps to Reproduce the behavior
With IMDSv2 enforced, attempt to use the s3 module either on its own or in a state (i.e. file.managed with s3://{bucket} as the source). The call will fail with:

[WARNING ] Failed to decode JSON from instance metadata.
Error running 's3.get': Failed s3 operation. InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.

Expected behavior
The s3 module should be able to retrieve proper credentials for subsequent calls to s3 api and the s3 module should work with no additional setup.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3003.1

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.6.1
     docker-py: 2.5.1
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10
       libgit2: 0.26.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.4.7
        pygit2: 0.26.2
        Python: 3.6.9 (default, Jan 26 2021, 15:33:00)
  python-gnupg: 0.4.1
        PyYAML: 3.12
         PyZMQ: 17.1.2
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.2.5

System Versions:
          dist: ubuntu 18.04 Bionic Beaver
        locale: UTF-8
       machine: x86_64
       release: 5.4.0-1041-aws
        system: Linux
       version: Ubuntu 18.04 Bionic Beaver

Additional context
See also #57514

@ryanm-sq ryanm-sq added Bug broken, incorrect, or confusing behavior needs-triage labels Aug 3, 2021
@welcome
Copy link

welcome bot commented Aug 3, 2021

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@OrangeDog OrangeDog added boto AWS wrapper modules severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around and removed needs-triage labels Aug 17, 2021
@OrangeDog OrangeDog added this to the Approved milestone Aug 17, 2021
@ryanm-sq
Copy link
Author

It's been a year since this was opened. Any updates on this?

@block-erichter
Copy link

Bumping this as its impacting my team as well. Our AWS policy forces IMDSv2 so this is crucial.

@jdelnano
Copy link

Bumping the bump: Being able to use IMDSv2 is a best security practice, and having this support is critical for encouraging use of IMDSv2.

@Ch3LL
Copy link
Contributor

Ch3LL commented Sep 20, 2023

Closed by #63067

@Ch3LL Ch3LL closed this as completed Sep 20, 2023
@Ch3LL
Copy link
Contributor

Ch3LL commented Sep 20, 2023

Actually looking a bit closer at the code I'm not certain it was fixed by this PR. Can someone confirm if this is still broken on the latest version of Salt?

@Ch3LL Ch3LL reopened this Sep 20, 2023
@lorengordon
Copy link
Contributor

Yeah I tested it, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boto AWS wrapper modules Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

8 participants