You can upload and download from AWS S3 inside val functions.

In this guide, you’ll create an AWS bucket, an IAM user, and then test your set up is correct by uploading and downloading a small text file.

1. Create an AWS bucket

Log in to the AWS Console and go to https://s3.console.aws.amazon.com/s3/bucket/create

Create a new bucket by choosing a Bucket name (leave the defaults for everything else).

Screenshot 2023-06-28 at 13.43.58.png

Save the Bucket name and your AWS region as Val Town secrets as awsS3Bucket and awsS3Region respectively. Although these values aren’t secrets, doing this means you can copy and paste the val examples in this guide without making any code changes.

Continue to use this AWS region for the rest of this guide.

2. Create an IAM user

Go to https://console.aws.amazon.com/iamv2/home#/users and click Add users.

Screenshot 2023-06-28 at 13.48.12.png

Choose a User name.

Screenshot 2023-06-28 at 13.55.57.png

Select Attach policies directly.

Screenshot 2023-06-28 at 13.56.10.png

Give this user AmazonS3FullAccess by searching and selecting the checkbox under Permissions policies.

(This allows this user the highest level of S3 permissions across all of the buckets for the AWS account you’re logged into. Consider setting up granular permissions with AWS’s Bucket owner granting its users bucket permissions guide.)

Screenshot 2023-06-28 at 13.56.25.png

On the final page, click Create user.

3. Create access keys for the user