kahing / goofys

a high-performance, POSIX-ish Amazon S3 file system written in Go
Apache License 2.0
5.2k stars 522 forks source link

NoCredentialProviders error surfaces when using goofys on ec2 instances with IMDSv2 enabled. #671

Open TheBIsReal opened 2 years ago

TheBIsReal commented 2 years ago

Greetings 👋

I´m struggling to auto-mount my bucket using fstab with the following configuration: /usr/sbin/goofys#mybucketname /mnt/data fuse _netdev,allow_other,--file-mode=0660,--dir-mode=0770,--uid=1000,--gid=1000 0 0

When executing mount -a goofys fails with the messages seen below:

s3.INFO Switching from region 'us-east-1' to 'eu-west-1'
s3.ERROR code=NoCredentialProviders msg=no valid providers in chain. Deprecated.#012#011For verbose messaging see aws.Config.CredentialsChainVerboseErrors, err=<nil>
s3.ERROR code=NoCredentialProviders msg=no valid providers in chain. Deprecated.#012#011For verbose messaging see aws.Config.CredentialsChainVerboseErrors, err=<nil>
main.ERROR Unable to access 'mybucketname': NoCredentialProviders: no valid providers in chain. Deprecated.#012#011For verbosemessaging see aws.Config.CredentialsChainVerboseErrors
main.FATAL Mounting file system: Mount: initialization failed

We are operating on an ec2 instance using IMDSv2. Previously we used IMDSv1 without any issues. Once we´ve upgraded to v2 for our ec2-instances, the described issue occured without any additional change.

Have you any idea why goofys does not find the credentials of the ec2 instance role?

Kind regards, Bastian

llamafilm commented 12 months ago

This issue is already fixed in the latest code, but it hasn't been released yet so you have to build from source, as mentioned in #727.

bebosudo commented 11 months ago

Thanks @llamafilm, your comment helped me realize that the latest goofys release may not contain the IRSA feature, so I rebuilt it and now goofys is mounting S3 buckets using IAM roles!

Here are some steps I did in a ubuntu container on EKS to build goofys, which may be useful to others too:

$ curl -L https://go.dev/dl/go1.21.4.linux-amd64.tar.gz > go1.21.4.linux-amd64.tar.gz
$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.4.linux-amd64.tar.gz
$ export PATH=$PATH:/usr/local/go/bin
$ export GOPATH=$HOME/work
$ go install github.com/kahing/goofys@350ff31
$ ~/work/bin/goofys ${BUCKET_NAME} /media

@kahing any possibility to trigger a new rebuild of goofys? The latest release is very old.. Thanks a lot for this project!