I would like to put my Strapi Headless CMS to Heroku and connect it to the AWS S3 server. Because otherwise, Heroku are regularly clearing all my blog posts as well as users.
- I created AWS S3 bucket,
provided Public Read and List access to everything
- set up Cross-origin resource sharing (CORS) to:
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST",
"PUT"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
created a User in IAM (Identity and Access Management) provided him AmazonS3FullAccess get his Access key ID & Secret access key
then in my Strapi backend terminal (connected to Heroku) I setup the following:
heroku config:set AWS_ACCESS_KEY_ID=*** AWS_SECRET_ACCESS_KEY=***
heroku config:set S3_BUCKET_NAME=mielenyvin
heroku config:set AWS_URL=https://mielenyvin.s3.amazonaws.com/
heroku config:set AWS_S3_REGION_NAME=us-east-2
But nothing happens. All the posts from my database as well as roles and permissions still disappearing from Heroku after couple hours or so. And nothing appearing in my AWS S3 bucket when I am adding a new post.
./config/database.js content:
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'sqlite',
filename: env('DATABASE_FILENAME', '.tmp/data.db'),
},
options: {
useNullAsDefault: true,
},
},
},
});
./config/env/production/database.js content:
const parse = require('pg-connection-string').parse;
const config = parse(process.env.DATABASE_URL);
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: config.host,
port: config.port,
database: config.database,
user: config.user,
password: config.password,
ssl: {
rejectUnauthorized: false
},
},
debug: false,
},
});