Skip to main content

Deployment tool for Amazon ECS

Project description

ecs-deplojo

Deployment tool for Amazon ECS.

Installation

pip install ecs-deplojo

.. start-no-pypi

Status

.. image:: https://readthedocs.org/projects/ecs-deplojo/badge/?version=latest :target: https://readthedocs.org/projects/ecs-deplojo/

.. image:: https://github.com/labd/ecs-deplojo/workflows/Python%20Tests/badge.svg :target: https://github.com/labd/ecs-deplojo/actions?query=workflow%3A%22Python+Tests%22

.. image:: http://codecov.io/github/LabD/ecs-deplojo/coverage.svg?branch=master :target: http://codecov.io/github/LabD/ecs-deplojo?branch=master

.. image:: https://img.shields.io/pypi/v/ecs-deplojo.svg :target: https://pypi.python.org/pypi/ecs-deplojo/

.. end-no-pypi

Usage

.. code-block:: console

Usage: ecs-deplojo [OPTIONS]

Options:
  --config FILENAME   [required]
  --var VAR
  --dry-run
  --output-path PATH
  --role-arn <optional arn>
  --help              Show this message and exit.

Example configuration

.. code-block:: yaml

---
cluster_name: example

environment:
    DATABASE_URL: postgresql://

task_definitions:
  web:
    template: task_definitions/web.json
    overrides:
      uwsgi:
        memory: 512
        portMappings:
          - hostPort: 0
            containerPort: 8080
            protocol: tcp
  manage:
    template: task_definitions/manage.json

services:
  web:
    task_definition: web

scheduled_tasks:
  cron-event:
    task_definition: web

before_deploy:
  - task_definition: manage
    container: uwsgi
    command: manage.py migrate --noinput

after_deploy:
  - task_definition: manage
    container: uwsgi
    command: manage.py clearsessions

Using SSM secrets

Warning secrets will become visible in the container's environent, use with caution

When you want to use the AWS SSM secrets in your configuration you can use the secrets section, however this needs some additional configuration within AWS

At first you need an AWS IAM role to use as the ECS execution role, this role needs access to the secrets in Secrets Manager or Parameter store and will only be used during the startup of your Docker container.

Example configuration:

.. code-block:: yaml

--
cluster_name: example

environment:
  NORMAL_ENV_VAR: value_of_variable

secrets:
  DATABASE_URL: /path/to/secret/DATABASE_URL

task_definitions:
  web:
    execution_role_arn: arn:aws:iam::<account_id>:role/execution_role_name
    template: task_definitions/web.json

services:
  web:
    task_definition: web

When the container is started the secrets are available as environment variables and hidden in the AWS ECS console, this is not recommended in production.

AWS Default VPC

When running your servers in the AWS default VPC you need networkMode="awsvpc" in your task definition JSON file, this will ensure that no hostnames are set for the containers, since this isn't supported by AWS.

AWS Fargate

Unlike EC2 based clusters AWS Fargate needs a execution_role_arn to work, this can be set in your service definition in the YAML file.

AWS Scheduled tasks

The configuration block 'scheduled_tasks' contains the name over the rule in EventBridge as key, and a reference to the task_definition whose taskDefinitionArn will be used to update the task definition on the scheduled target.

Example log output

.. code-block:: console

Starting deploy on cluster example (1 services)
Registered new task definition web:10
Starting one-off task 'manage.py migrate --noinput' via manage:10 (uwsgi)
Updating service web with task defintion web:10
Waiting for deployments
Waiting for services: web (0/2)
Waiting for services: web (1/2)
Waiting for services: web (2/2)
Deployment finished: web (2/2)
Starting one-off task 'manage.py clearsessions' via manage:10 (uwsgi)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecs_deplojo-0.11.0.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ecs_deplojo-0.11.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file ecs_deplojo-0.11.0.tar.gz.

File metadata

  • Download URL: ecs_deplojo-0.11.0.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ecs_deplojo-0.11.0.tar.gz
Algorithm Hash digest
SHA256 3850c18db73fde6d3d3779005216657d0089852c6c71b5d397af84e6f71dd0ef
MD5 482312e51d65ff6dfa78572c287ab10f
BLAKE2b-256 f9da903f7a0c8a4c9b511238a194e2b30d41baef0b1e5a04b436d91b9204f8a9

See more details on using hashes here.

File details

Details for the file ecs_deplojo-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: ecs_deplojo-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ecs_deplojo-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3021685664a8df191d2ca51db50030c406500c7257469913fa8009435d2cd991
MD5 010f39a83e2dfe379bd4494e3fe17982
BLAKE2b-256 210d2f4a7a14ba00d6a3cd1c0707d44184fc757dd479f3efd02b628c7d9c52ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page