Skip to content

Deploy Formbricks on a scalable AWS ECS Cluster with Terraform

Notifications You must be signed in to change notification settings

formbricks/AWS-ECS-Deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Formbricks 🤝 AWS

This repository provides the Terraform configuration to deploy and manage the Formbricks application on AWS. This project builds on top of the excellent Amazon ECS Blueprints developed by the AWS team. It leverages the following AWS services to deliver a scalable and reliable environment for the Formbricks application:

  • ECS on Fargate
  • Application Load Balancer
  • VPC
  • Cloud Map

AWS Architecture Diagram

AWS Architecture Diagram

Key Features

  • Fargate Workload: ECS Fargate simplifies container deployment by removing the need to manage EC2 instances.
  • Mixed Fargate Compute (Dedicated and Spot): Cost-effectiveness with availability guarantees.
  • Application Load Balancing: Distributes incoming traffic for high availability.
  • Networking: Secure and segmented public and private subnets across availability zones.
  • Service Discovery: Streamlined communication between services via private DNS.
  • Secrets Management(Optional): Integration with AWS Secrets Manager for secure storage and retrieval of sensitive data.

Quickstart

  1. Prerequisites
    • Terraform CLI: Ensure Terraform CLI is installed on your machine. For detailed instructions on installation, visit the Terraform Installation Guide.
    • AWS credentials (configured via environment variables or a profile) with administrator role access.
    • Clone the GitHub Repository.
    • Connection URL for PotrgesSQL Database.
  2. Deployment
    • Set AWS credentials:
      export AWS_ACCESS_KEY_ID=your_access_key
      export AWS_SECRET_ACCESS_KEY=your_secret_key
    • Deploy core infrastructure:

      This step provisions the VPC, ECS Cluster and Cloud Map.

      • Change directory to terraform/core-infra
      • Initialize Terraform: terraform init
      • Apply changes: terraform apply
      • More detailed instructions can be found here.
    • Deploy webapp infrastructure:

      This step provisions the ECS Service, ECS Task and Application Load Balancer.

      • Change directory to terraform/webapp-service
      • Initialize Terraform: terraform init
      • Generate values for NEXTAUTH_SECRET and ENCRYPTION_KEY: openssl rand -hex 32
      • Apply changes, providing configuration values:
        terraform apply -var "DATABASE_URL=your_db_connection_string" \
                        -var "NEXTAUTH_SECRET=your_nextauth_secret" \
                        -var "ENCRYPTION_KEY=your_encryption_key"
      • More detailed instructions can be found here.
  3. Access your application
    Locate the public DNS name or IP address of the Application Load Balancer in the AWS console or Terraform output.

⚠️ Important Notes ⚠️

  • Security: Use AWS Secrets Manager for storing and sharing sensitive information in production environments.
  • Destroy order: Destroy webapp service infrastructure before destroying core infrastructure.
  • Data persistence: Ensure adequate database provisions for production workloads.

Additional Information