donaldpiret / ecs-deploy

ECS deployment github action based on fabfuel/ecs-deploy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ecs-deploy

All Contributors

ECS deployment github action based on fabfuel/ecs-deploy

This action deploys ECS services using fabfuel/ecs-deploy package.

Usage

Deployment

Simple Redeploy

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName

Deploy a new tag

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  tag: 1.2.3

Deploy a new image

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  image: webserver nginx:1.11.8

Deploy several new images

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  image: webserver nginx:1.11.8, application my-app:1.2.3

Deploy a custom task definition

With a fully-qualified ARN

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  task: arn:aws:ecs:eu-central-1:123456789012:task-definition/my-task:20

With a task family name with revision

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  task: my-task:20

Or just a task family name. It this case, the most recent revision is used

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  task: my-task

Set an environment variable

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  env_vars: containerName SOME_VARIABLE SOME_VALUE

Adjust multiple environment variables

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  env_vars: containerName SOME_VARIABLE SOME_VALUE, containerName OTHER_VARIABLE OTHER_VALUE, appContainerName APP_VARIABLE APP_VALUE

Set environment variables exclusively, remove all other pre-existing environment variables

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  env_vars: containerName SOME_VARIABLE SOME_VALUE
  exclusive_env: true

Set a secret environment variable from the AWS Parameter Store or Secrets Manager

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  secrets: containerName SOME_SECRET arn:aws:ssm:<aws region>:<aws account id>:parameter/KEY_OF_SECRET_IN_PARAMETER_STORE

Set secrets exclusively, remove all other pre-existing secret environment variables

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  secrets: containerName SOME_SECRET arn:aws:ssm:<aws region>:<aws account id>:parameter/KEY_OF_SECRET_IN_PARAMETER_STORE
  exclusive_secrets: true 

Modify a command

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  command: containerName "nginx -c /etc/nginx/nginx.conf"

Set a task role

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  task_role: arn:aws:iam::123456789012:role/MySpecialEcsTaskRole

Ignore capacity issues

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  ignore_warnings: true

Disable task definition deregistration

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  no_deregister: true

Rollback on failure

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  rollback: true

Deployment timeout

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  timeout: 1200

To run a deployment without waiting for the successful or failed result at all, set timeout to the value of -1.

uses: donaldpiret/ecs-deploy@master
with:
  cluster: theClusterName
  target: theServiceName
  timeout: -1

Deploy a Scheduled Task (Cron) Update

The cron action deploys a new task definition to a Scheduled Task rule. The target should be a task definition family name, and the rule option must specify the CloudWatch Events rule name.

uses: donaldpiret/ecs-deploy@master
with:
  action: cron
  cluster: theClusterName
  target: taskName
  rule: ruleName
  image: application my-app:1.2.3

The following options work the same with cron as with deploy to update the task definition:

  • image
  • tag
  • env_vars
  • exclusive_env
  • task_role
  • command
  • no_deregister
  • rollback

Scaling

Scale a service

uses: donaldpiret/ecs-deploy@master
with:
  action: scale
  cluster: theClusterName
  target: theServiceName
  scale_value: 4

Running a Task

Run a one-off task

uses: donaldpiret/ecs-deploy@master
with:
  action: run
  cluster: theClusterName
  target: taskName:taskRevision

You can define environment variables just like for deploy

uses: donaldpiret/ecs-deploy@master
with:
  action: run
  cluster: theClusterName
  target: taskName:taskRevision
  env_vars: containerName SOME_VARIABLE SOME_VALUE, containerName OTHER_VARIABLE OTHER_VALUE, appContainerName APP_VARIABLE APP_VALUE

Run a task with a custom command

uses: donaldpiret/ecs-deploy@master
with:
  action: run
  cluster: theClusterName
  target: taskName:taskRevision
  command: my-container "python some-script.py param1 param2"

Run a task in a Fargate Cluster

uses: donaldpiret/ecs-deploy@master
with:
  action: run
  cluster: theClusterName
  target: taskName:taskRevision
  command: my-container "python some-script.py param1 param2"
  launch_type: FARGATE
  security_group: securityGroupID
  subnet: subnetID
  public_ip: true

Troubleshooting

I'm getting the error 'Unknown task definition arn'

Please make sure the service account is correctly set up and has the necessary IAM permissions. It might be related to a missing ecs:ListTaskDefinitions permission.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Simon Garner

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

About

ECS deployment github action based on fabfuel/ecs-deploy

License:MIT License


Languages

Language:Shell 89.6%Language:Makefile 5.5%Language:Dockerfile 3.3%Language:JavaScript 1.6%