Skip to main content

GitHub Action: deploy-ecspresso

Deploy on ECS with Escpresso

Introduction

This is template repository to create composite GitHub Actions. Feel free to use it as reference and starting point.

Usage

  name: Pull Request
on:
push:
branches: [ 'main' ]

jobs:
context:
runs-on: ubuntu-latest
steps:
- name: Example action
uses: cloudposse/example-github-action-deploy-ecspresso@main
id: example
with:
image: 1111111111111.dkr.ecr.us-east-2.amazonaws.com/cloudposse/example-app-on-ecs
image-tag: latest
region: us-east-2
operation: deploy
cluster: acme-plat-ue2-sandbox
application: acme-plat-ue2-sandbox-example-app-on-ecs
taskdef-path: taskdef.json

outputs:
result: ${{ steps.example.outputs.webapp-url }}

S3 Mirroring

S3 Mirroring is a pattern of uploading the deployed task definition to an S3 Bucket. This is so that the task definition can be updated with the latest image tag, and the terraform does not reset it back to a previous tag set in the infrastructure repository.

Partial Task Definition

A "Partial Task Definition" is an authoring pattern where the application repository maintains only the parts of the ECS task definition that the app team owns or changes frequently (for example, container image/tag, environment variables, command/args, CPU/memory for a container). The more static, infrastructure-owned parts (for example, IAM roles, volumes, EFS mounts, log configuration, task-level networking) are provided by a template maintained in the infrastructure repository.

During deployment, this action merges the infrastructure-provided template (optionally fetched from S3) with the local partial task definition from the application repo to produce a complete task-definition.json, which is then deployed by ecspresso.

S3 Mirroring

Inputs

NameDescriptionDefaultRequired
applicationApplication nameN/Atrue
clusterCluster nameN/Atrue
debugDebug modefalsefalse
ecspresso-versionEcspresso versionv2.1.0false
imageDocker imageN/Atrue
image-tagDocker image tagN/Atrue
mirror_to_s3_bucketMirror task definition to s3 bucketN/Afalse
operationOperation (valid options - deploy, destroy)deploytrue
regionAWS RegionN/Atrue
taskdef-pathTask definition pathN/Atrue
timeoutEcspresso timeout5mfalse
use_partial_taskdefinitionNOTE: Experimental. Load templated task definition from S3 bucket, which is created by the ecs-service component. This is useful when you want to manage the task definition in the infrastructure repository and the application repository. The infrastructure repository manages things like Volumes and EFS mounts, and the Application repository manages the application code and environment variables.N/Afalse

Outputs

NameDescription
webapp-urlWeb Application url