From 1e3c3d1e1ae616d8c76fbc901907d73c17cb06b1 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Thu, 14 May 2026 18:36:57 -0400 Subject: [PATCH] Add post-deploy health check template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Template script for project-specific health checks. Copy to scripts/health-check.sh — CD workflows run it automatically. --- scripts/health-check-template.sh | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 scripts/health-check-template.sh diff --git a/scripts/health-check-template.sh b/scripts/health-check-template.sh new file mode 100755 index 0000000..18d80d1 --- /dev/null +++ b/scripts/health-check-template.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Post-deploy health check template. +# Copy to your project as scripts/health-check.sh and customize. +# Called automatically by CD workflows after deploy. +# Args: $1 = stack name, $2 = AWS region + +set -euo pipefail + +STACK_NAME="${1:?Stack name required}" +REGION="${2:-us-east-1}" + +echo "Running health checks for ${STACK_NAME}..." + +# Example: verify a Lambda function is invocable +# FUNCTION_NAME="${STACK_NAME}-process-order" +# aws lambda invoke \ +# --function-name "$FUNCTION_NAME" \ +# --payload '{"healthCheck": true}' \ +# --region "$REGION" \ +# /tmp/health-check-response.json +# cat /tmp/health-check-response.json + +# Example: verify an EC2 instance is running +# INSTANCE_ID=$(aws cloudformation describe-stacks \ +# --stack-name "$STACK_NAME" \ +# --query 'Stacks[0].Outputs[?OutputKey==`InstanceId`].OutputValue' \ +# --output text --region "$REGION") +# STATE=$(aws ec2 describe-instances \ +# --instance-ids "$INSTANCE_ID" \ +# --query 'Reservations[0].Instances[0].State.Name' \ +# --output text --region "$REGION") +# if [[ "$STATE" != "running" ]]; then +# echo "ERROR: Instance $INSTANCE_ID is $STATE, expected running" +# exit 1 +# fi +# echo "Instance $INSTANCE_ID is running." + +# Example: verify an API Gateway endpoint responds +# API_URL=$(aws cloudformation describe-stacks \ +# --stack-name "$STACK_NAME" \ +# --query 'Stacks[0].Outputs[?OutputKey==`ApiUrl`].OutputValue' \ +# --output text --region "$REGION") +# HTTP_CODE=$(curl -sf -o /dev/null -w '%{http_code}' "$API_URL/health") +# if [[ "$HTTP_CODE" != "200" ]]; then +# echo "ERROR: API health endpoint returned $HTTP_CODE" +# exit 1 +# fi +# echo "API endpoint healthy." + +echo "All health checks passed."