https://prefect.io logo
Title
s

Steph Clacksman

02/23/2023, 3:31 PM
How can I create an s3 storage block with a session token? Is it possible to create an s3 storage block without using the UI?
d

David Steiner Sand

02/23/2023, 3:36 PM
Following the docs at the end of https://docs.prefect.io/concepts/storage/, you can create an s3 block in a python script using
from prefect.filesystems import S3
:
from prefect.filesystems import S3

block = S3(bucket_path="my-bucket/a-sub-directory", 
           aws_access_key_id="foo", 
           aws_secret_access_key="bar"
)
block.save("example-block")
Then deploy your flow pointing to the block name:
prefect deployment build ./flows/my_flow.py:my_flow --name "Example Deployment" --storage-block s3/example-block
s

Steph Clacksman

02/24/2023, 1:01 PM
Looking at the code for that class it seems there is no option to add a session token. Does that mean we can't use them?