项目作者: labd

项目描述 :
Deployment tool for Amazon ECS
高级语言: Python
项目地址: git://github.com/labd/ecs-deplojo.git
创建时间: 2015-10-29T15:37:24Z
项目社区:https://github.com/labd/ecs-deplojo

开源协议:MIT License

下载


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

  1. Usage: ecs-deplojo [OPTIONS]
  2. Options:
  3. --config FILENAME [required]
  4. --var VAR
  5. --dry-run
  6. --output-path PATH
  7. --role-arn <optional arn>
  8. --help Show this message and exit.

Example configuration

.. code-block:: yaml

  1. ---
  2. cluster_name: example
  3. environment:
  4. DATABASE_URL: postgresql://
  5. task_definitions:
  6. web:
  7. template: task_definitions/web.json
  8. overrides:
  9. uwsgi:
  10. memory: 512
  11. portMappings:
  12. - hostPort: 0
  13. containerPort: 8080
  14. protocol: tcp
  15. manage:
  16. template: task_definitions/manage.json
  17. services:
  18. web:
  19. task_definition: web
  20. before_deploy:
  21. - task_definition: manage
  22. container: uwsgi
  23. command: manage.py migrate --noinput
  24. after_deploy:
  25. - task_definition: manage
  26. container: uwsgi
  27. 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

  1. --
  2. cluster_name: example
  3. environment:
  4. NORMAL_ENV_VAR: value_of_variable
  5. secrets:
  6. DATABASE_URL: /path/to/secret/DATABASE_URL
  7. task_definitions:
  8. web:
  9. execution_role_arn: arn:aws:iam::<account_id>:role/execution_role_name
  10. template: task_definitions/web.json
  11. services:
  12. web:
  13. 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.

Example log output

.. code-block:: console

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