Skip to content

AWS CodePipeline Configuration

This document details the Continuous Integration/Continuous Deployment (CI/CD) pipeline configurations for AngelCX services using AWS CodePipeline.

Service Deployment Pipelines

Overview

The following services use identical pipeline configurations for automated Docker image builds and Lambda deployments:

  • Admin API
  • AI Engine
  • Post Session Service
  • AI Tools

Each service has two pipeline variants:

  • Development environment pipeline
  • Production environment pipeline (in respective AWS regions)

Pipeline Architecture

sequenceDiagram participant Bitbucket participant CodePipeline participant CodeBuild participant ECR participant Lambda participant APIGateway Bitbucket->>CodePipeline: New commit triggered CodePipeline->>CodeBuild: Start build process CodeBuild->>ECR: Build & push Docker image CodeBuild->>Lambda: Update function with new image Lambda-->>APIGateway: Serve updated API

Build Process

The pipeline is triggered automatically when new commits are pushed to the repository. The process follows these steps:

  1. Source Stage: CodePipeline detects new commits in the Bitbucket repository
  2. Build Stage: CodeBuild executes the following:
    • Authenticates with Amazon ECR
    • Builds Docker image
    • Pushes image to ECR
    • Updates Lambda function with new image

BuildSpec Configuration

The following buildspec.yml configuration is used for all service deployments:

version: 0.2

phases:
  pre_build:
    commands:
      - set -e
      - echo Logging in to Amazon ECR...
      - aws --version
      - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI

  build:
    commands:
      - echo Build started on date
      - echo Building the Docker image...
      - docker build -t $REPOSITORY_URI:latest .

  post_build:
    commands:
      - echo Build completed on date
      - echo Pushing the Docker image...
      - docker push $REPOSITORY_URI:latest

      - echo Waiting 15 seconds for ECR to propagate the new image...
      - sleep 15

      - echo Verifying image is in ECR...
      - aws ecr describe-images --repository-name $REPOSITORY_NAME --image-ids imageTag=latest

      - echo Updating Lambda function with new image...
      - aws lambda update-function-code --function-name $FUNCTION_NAME --image-uri $REPOSITORY_URI:latest

artifacts:
  files:
    - "**/*"

Environment Variables

The following environment variables are configured in the CodeBuild project:

  • AWS_REGION: Target AWS region for deployment
  • REPOSITORY_URI: ECR repository URI
  • REPOSITORY_NAME: ECR repository name
  • FUNCTION_NAME: Target Lambda function name

Bot UI Script Deployment Pipeline

Overview

A separate pipeline handles the deployment of the main-embed-loader.js script from the bot-ui repository.

Pipeline Architecture

sequenceDiagram participant Bitbucket participant CodePipeline participant S3 participant CloudFront Bitbucket->>CodePipeline: New commit triggered CodePipeline->>S3: Deploy script to bucket S3-->>CloudFront: Serve via CDN

Deployment Process

  1. Pipeline is triggered by new commits to the bot-ui repository
  2. Script is deployed to the angel-saas-{env} S3 bucket
  3. Changes are distributed via CloudFront CDN

Note

  • The script is served through a CloudFront distribution for improved performance
  • Due to CDN caching, changes may not be immediately visible
  • Cache invalidation can be performed manually if immediate updates are required

Monitoring and Troubleshooting

Common Issues

  1. Build Failures

    • Check CodeBuild logs for detailed error messages
    • Verify ECR authentication
    • Ensure correct environment variables are set
  2. CDN Cache Issues

    • Changes to bot-ui script may take time to propagate
    • Use CloudFront console for manual cache invalidation