Skip to content

DailyDesk AWS CDK Infrastructure

This repository contains the AWS CDK infrastructure code for the DailyDesk application and legacy services.

Note: This repository contains infrastructure for: - DailyDesk Frontend: The frontend service of the DailyDesk application - Development and Production environments - DailyDesk Backend: The backend service of the DailyDesk application - Development and Production environments

All stacks are deployed to AWS account 858695866949 in the us-east-1 region.

Stack Names and Environments

DailyDesk Stacks

  • Dev: dailydesk-dev-stack
  • Production: dailydesk-production-stack

Prerequisites

Required Versions

  • Node.js: 18.x or higher (current project supports Node 18+)
  • npm: Latest version compatible with Node.js 18+
  • AWS CLI: Latest version (aws configure)
  • AWS CDK CLI: Version 2.1033.0 (npm install -g aws-cdk@2.1033.0)
  • CDK Library: Version 2.231.0 (latest compatible with CDK 2.1033.0)

Local Installation Commands

# Install CDK CLI (global)
npm install -g aws-cdk@2.1033.0

# Install project dependencies
npm install

# Build the project
npm run build

Note: This project uses the latest CDK v2.1033.0 with Node.js 18+ support. Ensure version compatibility to avoid deployment issues.

Deployment Flow

We use a single parent stack to manage resources. The backend, frontend, and SSM resources are deployed as nested stacks.

DailyDesk Dev

  1. Preview Changes:
    npm run cdk:diff:dev
    # OR
    cdk diff dailydesk-dev-stack
    
  2. Deploy:
    npm run cdk:deploy:dev
    # OR
    cdk deploy dailydesk-dev-stack
    

DailyDesk Production

  1. Preview Changes:
    npm run cdk:diff:production
    # OR
    cdk diff dailydesk-production-stack
    
  2. Deploy:
    npm run cdk:deploy:production
    # OR
    cdk deploy dailydesk-production-stack
    

Important Notes

  • Always run cdk diff before cdk deploy to review changes
  • Ensure you have the correct AWS credentials and permissions
  • Production deployments should be coordinated and tested thoroughly
  • Context cache can be cleared with cdk context --clear if needed

Configuration Management

This CDK infrastructure uses a configmap-like approach for managing SSM parameter values. Configuration values are stored in JSON files and loaded during CDK deployment.

Configuration Files

Configuration files are located in the configmaps/ directory: - configmap.dev.json - Development environment configuration - configmap.production.json - Production environment configuration

Each configuration file contains an array of ssmParameters objects.

Example config file structure:

{
  "ssmParameters": [
    {
      "id": "WebsiteBucketNameParameter",
      "parameterName": "s3/website-bucket-name",
      "value": "my-bucket-name",
      "description": "S3 bucket name for hosting the main frontend website"
    },
    ...
  ]
}

Adding New Environments

To add a new environment: 1. Create a new configuration file named configmap.{environment}.json in the configmaps/ directory 2. Populate the file with the required SSM parameter values following the structure above 3. Update the CDK stack instantiation in bin/cdk.ts to include the new environment

Updating Configuration Values

To update configuration values for an environment: 1. Edit the appropriate configmaps/configmap.{environment}.json file 2. Update the values as needed 3. Deploy the stack for that environment:

npm run cdk:deploy:<environment>
# e.g. npm run cdk:deploy:dev