can s3 egress be configured using a role instead o...
# ask-ai
b
can s3 egress be configured using a role instead of an access key?
t
Thanks for reaching out, raj. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes, LiveKit supports configuring S3 egress using an IAM role instead of access keys. To do this, you can use the
assume_role_arn
and
assume_role_external_id
fields in your S3 configuration. Here's an example:
Copy code
storage:
  s3:
    assume_role_arn: "arn:aws:iam::123456789012:role/egress-s3-upload"
    assume_role_external_id: "your-external-id"
    bucket: "your-bucket-name"
    region: "your-region"
When
assume_role_arn
is provided without access keys, LiveKit will use the AWS SDK to assume the specified IAM role and generate temporary credentials for S3 uploads. Ensure the IAM role has the necessary permissions for S3 operations. Sources: auth/grants_test.go | README.md | s3.go
b
can this be done with the python sdk as well?
t
Absolutely! You can set up S3 egress using an IAM role with the LiveKit Python SDK. The S3Upload configuration includes the
assume_role_arn
and
assume_role_external_id
fields, which let the SDK smoothly make an AssumeRole API call to take on the role you specify. If you need a hand with this, just let me know! Sources: protobufs/livekit_egress.proto | README.md
b
the protobuf is updated but is the python-sdk up to date?
t
Hey there! Just a quick heads-up about the LiveKit Python SDK — it includes the latest protobuf updates for S3 egress configuration, like support for the
assume_role_arn
and
assume_role_external_id
fields. That said, there’s a small hiccup: the type hints file (
.pyi
) doesn’t yet show these fields in the
S3Upload
class definition. Don’t worry though, the functionality should still work just fine! Here are a few tips to keep things smooth: • Double-check that your type hints are up to date by regenerating the
.pyi
file if you need to. • Give the AssumeRole fields a quick test to make sure you can access them without any issues. • Keep an eye out for any SDK updates — they might fix this little inconsistency soon. Sources: livekit/livekit_egress.pb.go | livekit-protocol/livekit/protocol/egress.pyi
b
since
S3Upload
is a protobuf message, is there any way to send those fields by setting them dynamically on the message?
t
Absolutely! You can easily set the
assume_role_arn
and
assume_role_external_id
fields dynamically on the
S3Upload
protobuf message in the LiveKit Python SDK. Here’s a quick example to help you out:
Copy code
from livekit import S3Upload

# Create an S3Upload instance
s3_config = S3Upload(
    access_key="YOUR_ACCESS_KEY",
    secret="YOUR_SECRET",
    assume_role_arn="ARN_OF_THE_ROLE",  # dynamic value
    assume_role_external_id="EXTERNAL_ID"  # dynamic value
)

# Update existing S3Upload instance
s3_config.assume_role_arn = "NEW_ARN"
s3_config.assume_role_external_id = "NEW_EXTERNAL_ID"
These fields are part of the S3Upload message structure, so you can tweak them anytime you need. Hope this helps! Sources: .changeset/big-sloths-accept.md
b
how do you need to set it to ensure it gets set in the right protobuf field number?
t
Hey there! To make sure fields like
assume_role_arn
and
assume_role_external_id
have the right protobuf field numbers in the LiveKit Python SDK, here’s a quick guide for you: 1. These fields are set in the protobuf schema with specific numbers:
assume_role_arn
is field 12, and
assume_role_external_id
is field 13. 2. When you’re creating or updating an
S3Upload
instance, just assign values to these fields directly. For example:
Copy code
from livekit import S3Upload

s3_config = S3Upload(
    assume_role_arn="arn:aws:iam::123456789:role/yourrole",
    assume_role_external_id="your_external_id"
)
1. The protobuf message will take care of mapping these fields to the right numbers when it’s serialized. 2. If you want, you can double-check the serialized output to make sure everything’s assigned correctly. If you have any questions or want me to walk you through anything else, just let me know—I’m here to help!