from livekit import api async def entrypoint(ctx:...
# ask-ai
e
from livekit import api async def entrypoint(ctx: JobContext): req = api.RoomCompositeEgressRequest( room_name=ctx.room.name, audio_only=True, file_outputs=[ api.EncodedFileOutput( file_type=api.EncodedFileType.OGG, filepath="livekit/my-room-test.ogg", s3=api.S3Upload( bucket=os.getenv("AWS_BUCKET_NAME"), region=os.getenv("AWS_REGION"), access_key=os.getenv("AWS_ACCESS_KEY_ID"), secret=os.getenv("AWS_SECRET_ACCESS_KEY"), ), ) ], ) lkapi = api.LiveKitAPI() await lkapi.egress.start_room_composite_egress(req) await lkapi.aclose() # ... continue with your agent logic Will this work for ec2 if i provide a iam role to ec2 instead of providing explicit env vars
t
Thanks for reaching out, Aditya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether that code will work on EC2 if you rely on an instance IAM role instead of providing AWS creds via env vars. Yes — remove the
access_key
and
secret
fields from
api.S3Upload
and only provide
bucket
(and optionally
region
). When credentials are omitted, the Egress service uses the standard AWS credential chain, which includes the EC2 instance role. Ensure the EC2 role has S3 permissions (e.g.,
s3:PutObject
and
s3:PutObjectAcl
) for the target bucket. Example change:
Copy code
s3=api.S3Upload(
  bucket="your-bucket-name",
  region="us-west-2",
  # do not set access_key or secret — IAM role will be used
)
Would you like a checklist for required IAM permissions or help verifying the EC2 role?
e
Will this work with livekit managed service ? or i need to self host it ?
t
You're asking whether LiveKit Cloud supports using an EC2 IAM role for S3 uploads in egress or if you must self-host. LiveKit Cloud requires explicit AWS credentials (
access_key
and
secret
) for S3 egress. If you want the Egress service to use an EC2 instance IAM role (so you don't supply credentials), you need to self-host the Egress service on your EC2 instances. If you'd like, I can: • Provide the exact minimal IAM permissions needed for S3 uploads, or • Show the adjusted
S3Upload
example for LiveKit Cloud (with credentials filled) or for self-hosting (credentials omitted). Which would you prefer? Sources: Egress output types | LiveKit docs | Self-hosting the Egress Service | LiveKit docs