Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ecs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_call:
inputs:
image_tag:
description: "Container image tag to deploy"
description: "Container image tag (unused — kept for workflow_call compat)"
type: string
required: true
default: ""
service_name:
description: "ECS service name (defaults to repo name)"
type: string
Expand Down Expand Up @@ -59,8 +59,4 @@ jobs:
env:
SERVICE: ${{ inputs.service_name || github.event.repository.name }}
CLUSTER: ${{ inputs.cluster_name }}
IMAGE_TAG: ${{ inputs.image_tag }}
ECR_REPO: ${{ github.event.repository.name }}
ACCOUNT_ID: ${{ inputs.aws_account_id }}
REGION: ${{ inputs.aws_region }}
run: sh .platform/scripts/ecs-deploy.sh
25 changes: 8 additions & 17 deletions scripts/ecs-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
#!/bin/sh
# Deploy a new container image to an ECS service.
#
# Forces a new deployment so ECS pulls the latest image for the current
# task definition. Does NOT create new task definition revisions — that's
# Terraform's job. This avoids drift between TF-managed task defs
# (with security hardening, volumes, etc.) and deploy-time revisions.
#
# Usage: ecs-deploy.sh
#
# Env: CLUSTER, SERVICE, ECR_REPO, IMAGE_TAG, ACCOUNT_ID, REGION
# Env: CLUSTER, SERVICE

set -e

SCRIPT_DIR=$(dirname "$0")
export ECR_URI="${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/${ECR_REPO}:${IMAGE_TAG}"

# Use the latest family revision (includes structural changes from Terraform)
# rather than the revision currently running on the service.
aws ecs describe-task-definition --task-definition "$SERVICE" \
--query 'taskDefinition' > task-def.json

sh "$SCRIPT_DIR/update-task-def.sh" task-def.json task-def-new.json

NEW_ARN=$(aws ecs register-task-definition \
--cli-input-json file://task-def-new.json \
--query 'taskDefinition.taskDefinitionArn' --output text)
echo "New task definition: $NEW_ARN"

echo "Forcing new deployment for ${SERVICE} on ${CLUSTER}..."
aws ecs update-service \
--cluster "$CLUSTER" --service "$SERVICE" \
--task-definition "$NEW_ARN" > /dev/null
--force-new-deployment > /dev/null

echo "Waiting for service to stabilize..."
aws ecs wait services-stable --cluster "$CLUSTER" --services "$SERVICE"
Expand Down
24 changes: 0 additions & 24 deletions scripts/update-task-def.sh

This file was deleted.

4 changes: 0 additions & 4 deletions terraform/modules/ecs-service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,5 @@ resource "aws_ecs_service" "this" {
container_port = var.port
}

lifecycle {
ignore_changes = [task_definition]
}

depends_on = [aws_ecs_task_definition.this]
}