From 03643d91f577b334957101941cb4bfcaefefd0a5 Mon Sep 17 00:00:00 2001 From: Jairo Vadillo Date: Mon, 20 Apr 2020 10:29:58 +0200 Subject: [PATCH] Add disable logs capabilities (#22) --- CHANGELOG.md | 5 +++++ ecs_deployer/task_definition.py | 20 +++++++++++--------- tests/data/sample_procfile.yml | 1 + tests/test_services.py | 3 ++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d09f1c..1cfbbea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## 0.1.1 (20-04-2020) + +### Changes: + - Add disable-logs parameter to procfile.yml + ## 0.1.0 (18-11-2019) ### Changes: diff --git a/ecs_deployer/task_definition.py b/ecs_deployer/task_definition.py index 4cbc354..d18f3c1 100644 --- a/ecs_deployer/task_definition.py +++ b/ecs_deployer/task_definition.py @@ -15,7 +15,7 @@ def create_task_definition(execution_role, memory, cpu, task_role=""): def create_container_definition(env_vars, environment, project_name, container_name, ecr_path, command, cpu=256, - memory=512, ports=None): + memory=512, ports=None, disable_logs=False): container_definition_name = "{}-{}".format(environment, project_name) log_path = "/ecs/{}-{}-{}".format(environment, project_name, container_name) @@ -37,14 +37,6 @@ def create_container_definition(env_vars, environment, project_name, container_n "name": container_definition_name, "mountPoints": [], "image": ecr_path, - "logConfiguration": { - "logDriver": "awslogs", - "options": { - "awslogs-stream-prefix": "ecs", - "awslogs-group": log_path, - "awslogs-region": "eu-west-1" - } - }, "cpu": cpu, "memory": memory, "portMappings": port_mappings, @@ -53,6 +45,16 @@ def create_container_definition(env_vars, environment, project_name, container_n "volumesFrom": [] } + if not disable_logs: + container_definition["logConfiguration"] = { + "logDriver": "awslogs", + "options": { + "awslogs-stream-prefix": "ecs", + "awslogs-group": log_path, + "awslogs-region": "eu-west-1" + } + } + return container_definition diff --git a/tests/data/sample_procfile.yml b/tests/data/sample_procfile.yml index 9611830..382c8a3 100644 --- a/tests/data/sample_procfile.yml +++ b/tests/data/sample_procfile.yml @@ -4,6 +4,7 @@ web: cpu: 256 ports: - 8000:8000 + disable-logs: true release: command: python --version memory: 1024 diff --git a/tests/test_services.py b/tests/test_services.py index 8609377..0d364ac 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -16,7 +16,8 @@ def test_read_good_procfile(): 'command': "ddtrace-run gunicorn --pythonpath app,app/apps app.wsgi:application --workers 4 --threads 4 --preload -b 0.0.0.0:8000 --timeout 90", 'memory': 512, 'cpu': 256, - 'ports': ['8000:8000'] + 'ports': ['8000:8000'], + 'disable-logs': True }, 'release': { 'command': "python --version",