Deploying Strapi to AWS with Flightcontrol

Strapi is an open-source headless Content Management System (CMS) that enables developers to build projects faster by providing a customizable API and allowing them to use their favorite tools. This tutorial will provide detailed steps on how to deploy your Strapi project on Flightcontrol.

Prerequisites

Make sure you’ve completed the following before proceeding with this guide:

Configuration Options

Follow these steps to deploy your Strapi application using the GUI configuration type:

  1. Select a configuration type of “GUI”
  2. Select an environment
  3. Select a service
  4. Strapi requires that the following environment variables be set on Flightcontrol for the remote instance:
  • JWT_SECRET
  • ADMIN_JWT_SECRET
  • API_TOKEN_SALT
  • APP_KEYS
  • TRANSFER_TOKEN_SALT
  1. Adjust configuration as needed
  2. Click “Create Project” and complete any required steps (like linking your AWS account and adding the required environment variables)

Environment Variable Definitions

VariableDescriptionExample
JWT_SECRETThis is used to set the secret key for JSON Web Token (JWT) authentication. It is often used for authentication and authorization purposes.JWT_SECRET = tH0iS19ktGyVxJfbQc6TIT
ADMIN_JWT_SECRETThis is used to set the secret key specifically for the administration panel’s JSON Web Token (JWT) authentication.ADMIN_JWT_SECRET = 5Mt/XPHdS0IBP21wCXo4OG
API_TOKEN_SALTThis is used to define a secret salt value that is used when generating API tokens.API tokens are used for authentication and authorization purposes in Strapi’s API endpoints.API_TOKEN_SALT = VdANubbaOqpys5wROHz/tA
APP_KEYSThis is used to encrypt and decrypt sensitive data stored in the database or transmitted over the network. They ensure that only authorized parties can access encrypted data.APP_KEYS = VdAMubba9qpys3wKPHx/tA
TRANSFER_TOKEN_SALTThis serves as an encrypted salt for generating transfer tokensTRANSFER_TOKEN_SALT = VdAMu+bba9qpys3wKPHTtA
DATABASE_CLIENTThis is used to specify the type of database client that Strapi should use to connect to your database.DATABASE_FILENAME = sqlite
DATABASE_FILENAMEThis is used to specify the filename of the database file used by Strapi.DATABASE_FILENAME = .tmp/data.db

Support Image Uploads With Cloudinary

Strapi CMS requires a shared storage to upload images and other files. Flightcontrol deploys to containers, during this process there is a risk that file systems might get erased on re-deploys. Cloudinary fixes this problem by providing a cloud-based storage system which allows users to create, manage, and deliver dynamic visual experiences for websites and apps.

Installation

npm install @strapi/provider-upload-cloudinary

Configuration

For information about installing and using a provider visit documentation about using a provider. To learn more about how Strapi utilizes environment variables, please refer to the documentation about environment variables.

Example

config/plugins.js
module.exports = ({env}) => ({
  // ...
  upload: {
    config: {
      provider: "cloudinary",
      providerOptions: {
        cloud_name: env("CLOUDINARY_NAME"),
        api_key: env("CLOUDINARY_KEY"),
        api_secret: env("CLOUDINARY_SECRET"),
      },
      actionOptions: {
        upload: {},
        uploadStream: {},
        delete: {},
      },
    },
  },
  // ...
})

Security Middleware Configuration

In order to make changes to the default settings in the Strapi Security Middleware, it is necessary to modify the contentSecurityPolicy settings to see thumbnail previews in the Media Library properly. The strapi::security string should be replaced with the object below, as explained in the middleware configuration documentation.

config/middlewares.js
module.exports = [
  // ...
  {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": ["'self'", "data:", "blob:", "dl.airtable.com", "res.cloudinary.com"],
          "media-src": ["'self'", "data:", "blob:", "dl.airtable.com", "res.cloudinary.com"],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
]

Setting Cloudinary Configurations

  1. Create an account https://cloudinary.com/
  2. Navigate to Getting Started
  3. Set up the work environment according to the framework you are using
  4. Copy the Cloudinary Config
  5. Paste the new variables in your .env file.

Note

The naming convention in the environment configuration in the Flightcontrol Dashboard has to match with the keys under providerOptions in ./config/plugins.js

CLOUDINARY_NAME=********
CLOUDINARY_KEY=**********
CLOUDINARY_SECRET=***********

Support Image Uploads With Amazon S3

Follow instructions at How to Set up Amazon S3 Upload Provider Plugin for Your Strapi App

Conclusion

In this tutorial, you deployed a Strapi project using the Flightcontrol Dashboard or flightcontrol.json file. You also learned how to add Cloudinary and AWS S3 Bucket plugins to your Strapi project.