Skip to content

How to host CxReports on Amazon ECS

Disclaimer

This hosting guide does not cover the advanced features as load balancers, scaling, custom domains, specific networking setups or production-ready security practices.

If you want such features taken care of and don't have the means to manage it, we recommend choosing one of our cloud packages.

1. VPC - Virtual Private Cloud

Create a VPC that will be used. For testing purposes, default VPC that is already present can be used.

2. Subnet

Create a subnet for the VPC that the app will use. For testing purposes, default VPC that is already present can be used.

3. Database

The app needs a database and If you do not have an RDS instance that you could use, this is how to fire one up:

  • Engine options: PostgreSQL.
  • Templates: Free tier.
  • Settings:
    • Credential settings: Under Credentials management select Auto generate password.
  • Connectivity:
    • Virtual private cloud (VPC): Select the one you chose to use in step 1.
    • VPC security group (firewall): Leave Choose existing if you are using the default VPC with the default security groups or adjust if you have created a separate VPC and respective security group.
  • Proceed to create the database.
  • The end result of completing this section is the ability to add complete value for the connection database string key in the next step:
    • Database Endpoint (Host) Example: database-1.cracke26qdd3.eu-central-1.rds.amazonaws.com
    • Database Name Example: cxreportstest
    • Database Username Example: postgres
    • Database Password Example: Check the note below.

    Important

    Note down the auto generated password from the banner. Once the database has been created, you will need the host name (endpoint) in order to create the DB connection string. You can get it by navigating to the database and copying it from the Connectivity & security tab.

4. ECS - Task Definition

Navigate to Task definition within ECS service in order to create a new task definition:

  • Task definition family: Provide a task definition family name
  • Infrastructure requirements:
    • Launch type: AWS Fargate.
    • Operating system/Architecture: Linux/X86_64.
    • Task size: Set the CPU to 1 vCPU and the Memory to 3 GB.
  • Container - 1 section:
    • Container details: Specify the Name of the container and set the Image URI to codaxy/cx-reports:latest.
    • Port mapping: Set Container port as 8080, Protocol as TCP and App protocol as HTTP
    • Read only root file system: Enable the Read only option.
  • Environment variables:

    • Add individually: Add the following keys and values:
    Key Value type Value
    ConnectionStrings__Database Value Host=your-database-endpoint-from-step-3;Database=the-name-of-the-database-that-you-defined;Username=*postgres*;Password=master-password-you-got-from-step-3
    Encryption__Key Value see the note below
    Encryption__Vector Value see the note below
    RootUser__Email Value replace-with-your-custom-email-address
    RootUser__Password Value replace-with-your-custom-password
    RootUser__DisplayName Value replace-with-your-custom-display-name

    Note

    Copy the highlighted values as they are in the tutorial. Replace all other values with custom ones. To set up key and vector visit encryption section.

5. ECS - Cluster

Navigate to ECS to create a container cluster, set the following options as described and leave all other default as they are:

  • Cluster configuration:
    • Cluster name: Provide a name of the cluster, for example 'CxReports_Test_Cluster'.
  • Infrastructure:
    • Check AWS Fargate (serverless) and proceed to create the cluster.

6. ECS - Service

Go inside of the new cluster that you created in step 5. to create a new service:

  • Compute configuration:
    • Compute options: Select Capacity provider strategy.
    • Capacity provider: Select FARGATE with Base being 1 and Weight being 1.
    • Platform version: Select the LATEST option.
  • Deployment configuration:
    • Aplication type: Select the Service option..
    • Task definition: Under Family section select the task definition that you created in step 4.
    • Service name: Add a service name.
  • Networking:
    • VPC: Select the VPC that you created in step 1. or the default one that you have.
    • Subnets: Choose the subnets that you created in step 2. or select the default ones that you have.
    • Security groups: Select the default one or create a new one.

      Note: Select a security group that can accept traffic to port 8080.

  • Public IP: Enable the Turned on option.

7. Accessing your instance

  1. Navigate to the newly created service
  2. Select Task tab
  3. On the task dashboard, select the task that is running
  4. Navigate to the Networking tab
  5. The IP address is located under Public IP section