Automating Dump Generation for ECS Fargate Tasks

Contents

1. Automation Architecture

Post image 1

2. GitLab Pipeline

Post image 2

  • package : Create an archive containing only the files needed by the Lambda function
  • configuration : Update Lambda environment variables and reserved concurrency
    I collected the variable names declared as environment variables in env.json, substituted their values with sed, and arranged for the AWS CLI command to read the contents of env.json to update the environment variables.

Post image 3

Post image 4

3. Lambda Function

Post image 5

  • lambda_function.py : Describes the overall function behavior
  • function.py : Details the internal functions called by lambda_function.py
    * Function A - Collects the list of commands to run with ECS execute-command
    * Function B - Looks up the ECS Task ARN values for ECS execute-command
    * Function C - Runs ECS execute-command using the return values from functions A and B
  • script/dump.sh : Generates a dump inside the ECS Task based on CloudWatch metrics and uploads it to an S3 bucket

Diagram

100%

Drag to pan; pinch or use the wheel to zoom. Keyboard: arrow keys pan, + − zoom, 0 fits, Esc closes. The same content is in “Read the diagram as text” below the figure.