I am using Spree 3.1. To use Heroku, I need AWS S3 tp store pictures. Spent so much time with KeyError both local and Heroku.
And like to share here:
In AWS S3 document to create IAM USER for ID and access_key_id and secret_access_key. To make it work, I need to create profile and set admin permission.
Only paste this in needs environment eg: config/environments/production.rb and development.rb
config.paperclip_defaults = {
storage: :s3,
s3_credentials: {
bucket: ENV.fetch('S3_BUCKET_NAME'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
s3_region: ENV.fetch('AWS_REGION'),
}
}
Do not replace the value. Instead For Heroku:
heroku config:set S3_BUCKET_NAME=your-bucket-name AWS_ACCESS_KEY_ID=your-access-key-id AWS_SECRET_ACCESS_KEY=your-secret-access-key AWS_REGION=your-region
And for local: We add values in .env
$ cat .env
S3_BUCKET_NAME=your-bucket-name-development
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
Don't "quote" those values