Open jonathanasdf opened 2 years ago
I encountered the same problem. As a workaround, I used boto3
to get credentials and then set the environment variables manually. The Google auth library will use the environment variables instead of querying the EC2 metadata service.
import os
import boto3
from google.auth import environment_vars
aws_credentials = boto3.Session().get_credentials().get_frozen_credentials()
os.environ[environment_vars.AWS_ACCESS_KEY_ID] = aws_credentials.access_key
os.environ[environment_vars.AWS_SECRET_ACCESS_KEY] = aws_credentials.secret_key
os.environ[environment_vars.AWS_SESSION_TOKEN] = aws_credentials.token
Same issue here - running from Fargate, using google-auth 2.23.3. Thanks @tomwphillips for the workaround - works well.
Please note in my case the reported error was OSError: [Errno 22] Invalid Argument
@mmalecki that commit you have on your fork seems to do the trick for this -- any chance you could open a PR for that so we can try to get it into mainline?
Funny you should say this, I wrote it, then went on a weekly break without having had a chance to test this out, and was just getting back to it. Glad to hear it's working for you, I will open a PR.
@youcandanch now open as #1556
I've encountered the same issue here. I am using ECS and get a Transport error. Could you fix it? I think this issue was opened two years ago. I hope this issue will be fixed soon.
Getting metadata from plugin failed with error: HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /latest/meta-data/iam/security-credentials (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f99909b5fd0>: Failed to establish a new connection: [Errno 22] Invalid argument'))
Runs fine on EC2, but running on Fargate gives
Looking at https://stackoverflow.com/questions/57065458/cannot-access-instance-metadata-from-within-a-fargate-task it appears fargate has a different endpoint for iam metadata