Skip to main content

AWS ECS on EC2

This document guides you through installing Appsmith using AWS ECS on EC2

Prerequisites

1: Register with Amazon Web Services

If you already have an Amazon Web Services account, you may skip this step.

Please follow the steps detailed here to create an account on AWS.

2: Generate an SSH key pair

If you already have an SSH key pair for the AWS region you are operating in, you can skip this step.

Please follow the steps detailed here to generate a new key pair. You need this key to SSH into your AWS EC2 instance.

3: Create an AWS security group

If you already have an existing security group with ports 80, 443, 22, and 9001 open, you can skip this step.

Appsmith is a web application that requires ports 80 and 443 for HTTP access, port 22 to be accessible for SSH access, it also requires port 9001 to be accessible for the supervisord UI. Please follow the steps detailed here to create a new security group.

While creating the new security group, please follow the steps detailed here to edit the "Inbound Rules" and make ports 80, 443, 22 and 9001 accessible from anywhere.


ECS overview

ECS OVERVIEW

Deploy Appsmith (using EC2 launch type):

  1. Create an ECS Cluster
  2. Create Task and Container Definitions
  3. Create and Run an ECS Service
Important

Switch to the old AWS console UI to follow the steps in this tutorial.

Step 1: Create an ECS Cluster

  1. Navigate to Amazon ECS and choose clusters on the side bar and select Create Cluster.

Creating Cluster in AWS ECS

  1. Choose EC2 Linux + Networking, and select the next step.

  2. Enter your cluster name

  3. Instance configuration:

    1. Select the provisioning model as On-Demand Instance.
    2. Select the server size you wish to use, and set the Number of instances as 1.
    3. Select the Amazon Linux2 AMI for the EC2 AMI ID dropdown, and enter the required EBS volume size.
    4. Select a Key pair. Please refer to Prerequisite 2, if you haven't already created one.

    Configuring the instance

  4. Networking Section

    1. Select the default VPC followed by selecting the first subnet from the drop-down.
    2. Select the security group that you created in [Create an AWS security group] (#3-create-an-aws-security-group) section.

    Configuring the Networking Section

  5. Enable container insights (this gives CloudWatch monitoring and helps to debug).

  6. Leave the Container instance IAM role as default (ecsInstanceRole), if you don't have one AWS creates it for you.

  7. Hit the Create button. It may take a minute for your cluster to be ready.

ECS Cluster Status

Step 2: Create task and container definitions

Once the cluster is created, you need to create a task that runs on the cluster created in Step 1.

  1. On the sidebar, choose Task Definitions and select Create new Task Definition.

  2. Choose EC2 as the launch type, and proceed to the next step.

  3. Configure task and definition

    1. Enter the task definition name.

    2. Leave the Task role blank.

    3. Select the default Network mode

      Configuration of the Task

  4. Select the default Task execution IAM role (ecsTaskExecutionRole). AWS creates one for you if you don't have one.

  5. Set the required task size (memory & CPU)

  6. Go to the Volumes section and add a new volume. To persist data on the Appsmith installation you have two options.

    1. Bind mount directory on the host ec2 instance. The data is tied to the lifecycle of the host ec2 instance/ecs cluster. Enter the Name as appsmith_stack, set Volume type as Bind Mount, and set the Source path to /Appsmith/stacks. Bind Mount Volume Configuration

    2. Amazon EFS volumes- The data is independent of the lifecycle of the host ec2 instance/ecs cluster.

      1. Create an EFS filesystem by following the steps below:

        1. Navigate to AWS EFS on the console and hit the Create button.
        2. Set the parameters like VPC (should be the same as the ECS cluster) and storage class as suiting your requirement.
        3. Click on the EFS created and navigate to the Network tab to ensure mount-target is created in the same availability-zone as that of the ECS cluster.
        4. Create a new security group to allow inbound and outbound NFS traffic.
        5. Attach the security group to the ECS cluster and the EFS mount-target.
      2. Enter the Name as appsmith_stack, set Volume type as EFS and set the File System ID to the EFS filesystem created in the prequisite step. Leave the remaining fields with the default values.

        EFS Volume Configuration

  7. Configure Appsmith container.

    1. Click the Add container button.

    2. Enter the container name, and set the Image to appsmith/appsmith-ce

    3. Add port mappings for the ports 80->80,443->443

    4. Set the Mount points Source volume to appsmith_stack and set the Container path to /appsmith-stacks

      Storage Setting

    5. Enable auto-configure CloudWatch Logs for log configuration.

    6. Hit Add.

      Container Port Configuration

    7. Finally, hit the Create button.

Step 3: Create and run an ECS service

  1. Navigate to the clusters dashboard and click the ECS cluster created in [Step 1]/(aws-ecs#step-1-create-an-ecs-cluster).
  2. On the cluster details, under the Services tab hit the create button.

Cluster Dashboard

  1. Configure Service

    1. Select EC2 as Launch Type.

    2. Select the Task Definition created in Step 2 with the latest revision.

    3. Select the Cluster created in Step 1.

    4. Enter the service name.

    5. Select the Daemon Service type.

    6. Set the Minimum Healthy Percent to 40.

    7. Leave the remaining fields and sections with the default values, and proceed to the next step.

      Configuring the service

  2. Configure network - Proceed to the next step with the default configurations.

Configure Network

  1. Set Auto Scaling - Proceed to the next step with the default configuration.

Setting Up Auto Scaling

  1. Review the Service configurations and hit the Create Service button.

Review Section

  1. The following screen is shown with the launch status, click the View Service button.

Launch Status Dashboard

  1. You are directed to the service detail page. Your task is listed under the Tasks tab on the cluster. refresh the table until the status is RUNNING.

Service Detail Page

  1. Click on the task to get the details of your running service.

Task Dashboard

  1. Finally, click the EC2 instance id to navigate to the EC2 console with your ECS instance (which is basically an EC2 instance running the container service) listed.

EC2 Console

  1. Find the public IP address or DNS name and enter it on your browser to see Appsmith's welcome page.

Public IP Address

note

In this guide, If you are using the embedded MongoDB, the container persistence is tied up with the EC2 instance lifecycle.

Update Appsmith

caution

It's recommended to backup the Appsmith instance before performing an update. For more information, see How to create a backup.

  1. Navigate to the ECS cluster from the ECS dashboard.
  2. In the Tasks Tab, click the respective task.
  3. On the Task Page, hit the stop button.
  4. Wait until the new task is deployed automatically.

If you have updated your Appsmith instance and face any issues. You can rollback the changes and restore the Appsmith instance from a backup archive.

Troubleshooting

If you encounter any errors during this process, check out the debugging deployment errors, if you are still facing an issue please reach out to support@appsmith.com or join the Discord Server to directly speak to the Appsmith team.

Further reading