Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 2b0f8d2

Browse files
committed
updated log retention for backend tasks
1 parent d8bd9d5 commit 2b0f8d2

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

awscdk/awscdk/backend_tasks.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import os
22

3-
from aws_cdk import core, aws_ecs as ecs, aws_cloudformation as cloudformation
3+
from aws_cdk import (
4+
core,
5+
aws_ecs as ecs,
6+
aws_cloudformation as cloudformation,
7+
aws_logs as logs,
8+
)
49

510
# These tasks are executed from manual GitLab CI jobs. The cluster is
611
# specified with:
@@ -9,9 +14,16 @@
914

1015

1116
class BackendTasksStack(cloudformation.NestedStack):
12-
def __init__(self, scope: core.Construct, id: str, **kwargs,) -> None:
17+
def __init__(
18+
self,
19+
scope: core.Construct,
20+
id: str,
21+
**kwargs,
22+
) -> None:
1323
super().__init__(
14-
scope, id, **kwargs,
24+
scope,
25+
id,
26+
**kwargs,
1527
)
1628

1729
# migrate
@@ -28,7 +40,10 @@ def __init__(self, scope: core.Construct, id: str, **kwargs,) -> None:
2840
environment=scope.variables.regular_variables,
2941
secrets=scope.variables.secret_variables,
3042
command=["python3", "manage.py", "migrate", "--no-input"],
31-
logging=ecs.LogDrivers.aws_logs(stream_prefix="MigrateCommand"),
43+
logging=ecs.LogDrivers.aws_logs(
44+
stream_prefix="MigrateCommand",
45+
log_retention=logs.RetentionDays.ONE_DAY,
46+
),
3247
)
3348

3449
# collectstatic
@@ -79,6 +94,7 @@ def __init__(self, scope: core.Construct, id: str, **kwargs,) -> None:
7994
),
8095
command=["python3", "manage.py", "create_default_user"],
8196
logging=ecs.LogDrivers.aws_logs(
82-
stream_prefix="CreateSuperuserCommand"
97+
stream_prefix="CreateSuperuserCommand",
98+
log_retention=logs.RetentionDays.ONE_DAY,
8399
),
84100
)

backend/apps/core/management/commands/create_default_user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def handle(self, *args, **options):
1313
if not User.objects.all():
1414
print("Creating default user")
1515
User.objects.create_superuser(
16-
email="admin@company.com", password=password,
16+
email="admin@company.com",
17+
password=password,
1718
)
1819
print(
1920
"""

0 commit comments

Comments
 (0)