most-dawn-67700
11/18/2025, 6:24 AMS3 upload failed: operation error S3: PutObject, get identity: get credentials: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, http response error StatusCode: 404, request to EC2 IMDS failed
Here is my code block:
req = api.RoomCompositeEgressRequest(
room_name=ctx.room.name,
audio_only=True,
file_outputs=[api.EncodedFileOutput(
file_type=api.EncodedFileType.OGG,
filepath=f"recordings/{agent_name}/{ctx.room.name}_{current_date}.ogg",
s3=api.S3Upload(
bucket=AWS_BUCKET_NAME,
region=AWS_REGION,
access_key=os.getenv("AWS_ACCESS_KEY_ID"),
secret=os.getenv("AWS_SECRET_ACCESS_KEY"),
),
)],
)
lkapi = api.LiveKitAPI()
res = await lkapi.egress.start_room_composite_egress(req)
logger.info(f"[RECORDING] Recording started successfully: {res.egress_id}")
await lkapi.aclose()tall-airline-16756
11/18/2025, 6:24 AMtall-airline-16756
11/18/2025, 6:25 AMstorage.s3 section, or set them as environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. This works well if you’re not running on EC2 or if you’re not using IAM roles.
• Option 2: If you are running on an EC2 instance, the best approach is to assign an IAM role with the right S3 permissions to that instance. Make sure the role allows actions like PutObject and GetBucketLocation on the bucket you’re targeting.
Also, if you need to assume a different IAM role for your S3 uploads, you can specify the assume_role_arn in the egress request configuration, along with the necessary access_key and secret to perform the AssumeRole operation.
If you have any questions or want me to walk you through any of these steps, just let me know—I’m here to help!
Sources: go.sum | protobufs/livekit_egress.proto | go.summost-dawn-67700
11/18/2025, 6:27 AMaccess_key=os.getenv("AWS_ACCESS_KEY_ID"),
secret=os.getenv("AWS_SECRET_ACCESS_KEY"),
Is that something I have to manually configure in Livekit Cloud UI?tall-airline-16756
11/18/2025, 6:27 AMaccess_key=os.getenv("AWS_ACCESS_KEY_ID"),
secret=os.getenv("AWS_SECRET_ACCESS_KEY"),
Just a quick tip: please make sure that the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are correctly set and accessible in the environment where your code runs. If you’re still running into issues, it might help to double-check that the credentials have the right permissions for S3 operations like PutObject and GetBucketLocation on your target bucket. I’m here if you need any more help!
Sources: Web Egress | LiveKit Docs | Egress API | LiveKit docs