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

/vsis3/ unable to use IAM roles for service accounts (EKS, Kubernetes) #4058

Closed
scottyhq opened this issue Jul 2, 2021 · 5 comments
Closed
Milestone

Comments

@scottyhq
Copy link
Contributor

scottyhq commented Jul 2, 2021

Expected behavior and actual behavior.

A common setup for applications running on AWS EKS is to use IAM roles for service accounts. This way users don't have access to EC2 metadata, but are able to have IAM permissions associated with their running application. Currently, the GDAL tries searching for credentials in an ordered way using /vsis3/, but doesn't know how to get these credentials (search for "exchanging the Kubernetes-issued OIDC token for AWS role credentials" in this blog post for a technical explanation of how the credentialing works).

Steps to reproduce the problem.

It's hard to share a reproducible environment, but I think the following captures the issue:

  1. A user running on such a system has credentials as can be seen running aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************FR4R assume-role-with-web-identity    
secret_key     ****************3A9O assume-role-with-web-identity    
    region                us-west-2              env    ['AWS_REGION', 'AWS_DEFAULT_REGION']
  1. Using the AWS CLI it's possible to read from permitted S3 buckets: aws s3 ls s3://snowex-data/asf_vertex.png
                           PRE tutorial-data/
2021-07-02 16:40:58    1788203 asf_vertex.png
  1. GDAL tries to find local credential files (nonexistent), and ultimately tries directly for EC2 Instance metadata (HTTP: Fetch(http://169.254.169.254/latest/meta-data/iam/security-credentials which is typically blocked on K8s applications), and finally times out.
    CPL_DEBUG=ON CPL_CURL_VERBOSE=YES gdalinfo /vsis3/snowex-data/asf_vertex.png
HTTP: Fetch(http://169.254.169.254/latest/api/token)
HTTP: libcurl/7.77.0 OpenSSL/1.1.1k zlib/1.2.11 libssh2/1.9.0 nghttp2/1.43.0
HTTP: GDAL was built against curl 7.71.1, but is running against 7.77.0.
HTTP: These HTTP headers were set: X-aws-ec2-metadata-token-ttl-seconds: 10
* Couldn't find host 169.254.169.254 in the (nil) file; using defaults
*   Trying 169.254.169.254:80...
* Connection timed out after 1000 milliseconds
* Closing connection 0
gdalinfo failed - unable to open '/vsis3/snowex-data/asf_vertex.png'

Operating system

Ubuntu 20.04 running on a AWS EKS k8s 1.19 cluster

GDAL version and provenance

GDAL 3.2.1, released 2020/12/29 from conda-forge

@metasim
Copy link
Contributor

metasim commented Mar 23, 2022

Just discovered this problem also. Having to attach policy to node group to get it to work, which is not very secure.

@nsshah1288
Copy link

nsshah1288 commented Aug 31, 2022

Hi, I am using AWS EKS IAM roles for service accounts, and I am running into a similar issue. gdal version is 3.5.1

I saw that a bunch of commits were made to address this, but is there a gdal version that contains fixes for this? @rouault @ashangit @g8sqh

Error I am getting is
RasterioIOError: Read or write failed. '/vsis3/our-private-bucket/some-file.tif' not recognized as a supported file format.

I am able to read the same file in EKS using the AWS CLI fine (with aws s3 cp), but when trying to read the file with rasterio, it fails with the above error

Thanks!

@rouault
Copy link
Member

rouault commented Aug 31, 2022

implemented for upcoming 3.6.0 (nov 2022) per #6074

@rouault rouault added this to the 3.6.0 milestone Aug 31, 2022
@rouault
Copy link
Member

rouault commented Aug 31, 2022

Maybe update the documentation here

done in 05d0a0c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants