awslabs / amazon-transcribe-streaming-sdk

The Amazon Transcribe Streaming SDK is an async Python SDK for converting audio into text via Amazon Transcribe.
Apache License 2.0
142 stars 37 forks source link

SDK unable to use IAM credentials #7

Open anshitmt opened 3 years ago

anshitmt commented 3 years ago

This is more of a question than an issue. While the examples mentioned on the page work when I give provide access key and secret key via environment variable, it does not when I only assign IAM to the machine. I get the following error in the latter case:

[dev] File "/usr/local/lib/python3.7/site-packages/amazon_transcribe/client.py", line 90, in start_stream_transcription [dev] creds = await self._credential_resolver.get_credentials() [dev] File "/usr/local/lib/python3.7/site-packages/amazon_transcribe/auth.py", line 45, in get_credentials [dev] credentials = await asyncio.wrap_future(self._crt_resolver.get_credentials()) [dev] awscrt.exceptions.AwsCrtError: AwsCrtError(name='AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE', message='Valid credentials could not be sourced by the IMDS provider', code=6154)

I would like to understand if it is an expected product behaviour.

joguSD commented 3 years ago

it does not when I only assign IAM to the machine

Can you be a little more specific about your setup? Are you running this on EC2, ECR, Codebuild, etc?

anshitmt commented 3 years ago

I am running my code inside a docker container (pod) on a Kubernetes setup, which runs on a EC2 machine. We use kiam library to assign IAM roles to pods.

When I ssh into my pod, I am able to see the correct IAM role attached to my pod. I am also able to access other AWS services like S3 from the same pod, but when I use this SDK, I get the error mentioned in my previous post.

Eittipat commented 3 years ago

same

DaaS-20xx commented 2 years ago

I have the same issue, running the aws-transcribe-streaming-sdk in Docker. But when running my app outside of docker, it works (that means the aws service and IAM credentials are working).

TopCode111 commented 2 years ago

I also have the same issue.

parikls commented 2 years ago

Same one here! Doesn't work inside a Kubernetes POD. Can we expect that this will be fixed?

cderinbogaz commented 2 years ago

Same problem on Raspberry pi: File "/home/pi/.local/lib/python3.9/site-packages/amazon_transcribe/auth.py", line 45, in get_credentials credentials = await asyncio.wrap_future(self._crt_resolver.get_credentials()) awscrt.exceptions.AwsCrtError: AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE: Valid credentials could not be sourced by the IMDS provider

dejohansson commented 1 year ago

I'm getting the same error when authenticating with SSO. To get around it I use boto3 to fetch the credentials and then set the related environment variables.

import os
import boto3

credentials = boto3.Session().get_credentials()

os.environ["AWS_ACCESS_KEY_ID"] = credentials.access_key
os.environ["AWS_SECRET_ACCESS_KEY"] = credentials.secret_key
os.environ["AWS_SESSION_TOKEN"] = credentials.token
riccardobucco commented 2 months ago

This is still an issue..