Skip to content

AgentGino/aws-terraform-bytebase

Repository files navigation

Deploy Bytebase on AWS ECS with Terraform

This Terraform module provides a production-ready foundation for deploying Bytebase, the web-based, open-source Database DevOps tool, on Amazon Web Services (AWS).

The configuration uses a serverless and scalable architecture, leveraging AWS Fargate for container orchestration and Aurora Serverless v2 for database metadata storage.

What is Bytebase?

Bytebase is a powerful open-source tool that acts like "GitHub for database management." It provides a collaborative workspace for Developers and Database Administrators (DBAs) to manage the entire database development lifecycle safely and efficiently.

Key features include:

  • Database CI/CD: Standardize and automate the process of schema changes and data modification.
  • GitOps Integration: Manage your database schema as code by integrating with GitLab or GitHub.
  • Secure SQL Editor: A web-based IDE for teams to query data with built-in access control, data masking, and audit logging.
  • Security & Governance: Enforce SQL review policies, manage backup schedules, and control data access from a central platform.

This Terraform module makes it easy to get started with Bytebase on your own AWS infrastructure.

Architecture

This module provisions the following serverless and scalable architecture within a new or existing VPC:

alt Diagram

Core Components

  • Amazon ECS on AWS Fargate: A serverless compute engine for running the Bytebase container without managing servers.
  • Amazon Aurora Serverless v2: A highly available and auto-scaling PostgreSQL database for storing Bytebase metadata.
  • Application Load Balancer (ALB): Distributes traffic and provides SSL/TLS termination for secure HTTPS access.
  • Amazon Route 53: Manages the DNS records for your domain and handles SSL certificate validation.
  • AWS Secrets Manager: Securely stores and manages the database credentials.
  • AWS VPC: Creates an isolated network environment with public and private subnets for security.
  • Amazon CloudWatch Logs: Provides centralized logging for the Bytebase container.

Getting Started

1. Clone the Repository

git clone https://github.com/AgentGino/aws-terraform-bytebase
cd aws-terraform-bytebase

2. Configure Your Deployment

Create a terraform.tfvars file to specify your deployment settings.

# terraform.tfvars

# --- Required Variables ---
domain_name     = "bytebase.yourdomain.com"
route53_zone_id = "Z1234567890ABCDEF" # The Hosted Zone ID for yourdomain.com
aws_region      = "us-west-2"

# --- Optional Customizations ---
project_name               = "my-bytebase"
environment                = "prod"
bytebase_image             = "bytebase/bytebase:3.7.1" # Specify the Bytebase version

bytebase_cpu               = 1024
bytebase_memory            = 2048

db_serverless_min_capacity = 0.5
db_serverless_max_capacity = 4

vpc_cidr                   = "10.0.0.0/16"
availability_zones         = ["us-west-2a", "us-west-2b"]

tags = {
  Environment = "production"
  Project     = "Bytebase"
  ManagedBy   = "Terraform"
}

3. Initialize and Deploy

Run the following commands to deploy the infrastructure:

# Initialize Terraform providers and modules
terraform init

# Review the planned changes
terraform plan

# Apply the configuration to create the resources
terraform apply

The deployment process typically takes 10-15 minutes.

Accessing Bytebase

Once the terraform apply command completes:

  1. DNS propagation and SSL certificate issuance can take several minutes.
  2. Navigate to your chosen domain in a web browser: https://bytebase.yourdomain.com
  3. Follow the on-screen instructions in the Bytebase setup wizard to create your first admin user.
  4. Update External URL in the dashboard

Scaling

The compute and database resources can be scaled by adjusting your terraform.tfvars file and running terraform apply.

  • ECS Service (Bytebase Container):
    bytebase_cpu    = 2048  # e.g., 2 vCPU
    bytebase_memory = 4096  # e.g., 4 GB
  • Aurora Database: For production workloads, consider increasing the capacity.
    db_serverless_min_capacity = 2
    db_serverless_max_capacity = 16

Cleanup

To completely remove all deployed resources and avoid ongoing charges, run the destroy command:

terraform destroy

License

MIT

About

Terraform module to deploy Bytebase on AWS ECS Fargate with an Aurora Serverless v2 backend

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages