Uploading to AWS S3
Bolt has first-class support for uploading files to Amazon Web Services Simple Storage Service (AWS S3). This is necessary because some of the environments on which Bolt runs have ephemeral file systems.
Setting Up Bolt for AWS S3
The fine details of setting up your AWS S3 are beyond the scope of this book but there is more than enough material on it online.
- In your S3 account create a bucket to which Bolt will upload files. Note the name and the region of the bucket.
- Create an IAM user for Bolt. Note the Access Key ID and the Secret Access Key. The IAM user should have the right to upload files to your bucket.
- Create the environment variable
AWS_ACCESS_KEY_ID
to hold the access key ID mentioned above. - Create the environment variable
AWS_SECRET_ACCESS_KEY
to hold the secret access key mentioned above. - Create the environment variable
S3_BUCKET
to hold the name of the bucket. - Create the environment variable
S3_REGION
to hold the region of the bucket.
You can find a list of AWS regions here. Bolt signs requests to AWS S3 with signature version 4, so please use regions that support signature version 4 authentication (which is pretty much every region) . Now Bolt will upload files to your S3 buckets. The URL of such files are in the format: https://s3.<region>.amazonaws.com/<bucket>/<file name randomly set by Bolt>
.
note
Uploading to AWS S3 has been tested against only one region, us-east-2, which is US East (Ohio).