Skip to content

Commit

Permalink
Add disable logs capabilities (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairovadillo authored Apr 20, 2020
1 parent b493da8 commit 03643d9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
20 changes: 11 additions & 9 deletions ecs_deployer/task_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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


Expand Down
1 change: 1 addition & 0 deletions tests/data/sample_procfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ web:
cpu: 256
ports:
- 8000:8000
disable-logs: true
release:
command: python --version
memory: 1024
Expand Down
3 changes: 2 additions & 1 deletion tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 03643d9

Please sign in to comment.