Skip to content

Commit ccb63bc

Browse files
authored
feat: cdk.json could use poetry run #619 and misc fixes (#621)
1 parent 936588d commit ccb63bc

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ updates:
33
- package-ecosystem: "github-actions"
44
directory: "/"
55
schedule:
6-
interval: "daily"
6+
interval: "weekly"
77
commit-message:
88
prefix: chore
99
include: scope

cdk.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"app": "python app.py"
3-
}
2+
"app": "poetry run python app.py"
3+
}

cdk/my_service/api_construct.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from datetime import datetime
2+
13
from aws_cdk import CfnOutput, Duration, RemovalPolicy, aws_apigateway
24
from aws_cdk import aws_dynamodb as dynamodb
35
from aws_cdk import aws_iam as iam
46
from aws_cdk import aws_lambda as _lambda
5-
from aws_cdk import aws_logs
67
from aws_cdk.aws_lambda_python_alpha import PythonLayerVersion
8+
from aws_cdk.aws_logs import LogGroup, RetentionDays
79
from constructs import Construct
810
from my_service.api_db_construct import ApiDbConstruct # type: ignore
911

@@ -14,7 +16,7 @@ class ApiConstruct(Construct):
1416

1517
def __init__(self, scope: Construct, id_: str, appconfig_app_name: str) -> None:
1618
super().__init__(scope, id_)
17-
19+
self.id_ = id_
1820
self.api_db = ApiDbConstruct(self, f'{id_}db')
1921
self.lambda_role = self._build_lambda_role(self.api_db.db)
2022
self.common_layer = self._build_common_layer()
@@ -71,7 +73,7 @@ def _build_common_layer(self) -> PythonLayerVersion:
7173
def _add_post_lambda_integration(self, api_name: aws_apigateway.Resource, role: iam.Role, db: dynamodb.Table, appconfig_app_name: str):
7274
lambda_function = _lambda.Function(
7375
self,
74-
constants.SERVICE_ROLE,
76+
constants.CREATE_LAMBDA,
7577
runtime=_lambda.Runtime.PYTHON_3_9,
7678
code=_lambda.Code.from_asset(constants.BUILD_FOLDER),
7779
handler='service.handlers.create_order.create_order',
@@ -92,7 +94,13 @@ def _add_post_lambda_integration(self, api_name: aws_apigateway.Resource, role:
9294
memory_size=constants.API_HANDLER_LAMBDA_MEMORY_SIZE,
9395
layers=[self.common_layer],
9496
role=role,
95-
log_retention=aws_logs.RetentionDays.ONE_DAY,
97+
)
98+
99+
LogGroup(
100+
self,
101+
f'{self.id_}constants.CREATE_LAMBDA-{datetime.now()}',
102+
removal_policy=RemovalPolicy.DESTROY,
103+
retention=RetentionDays.ONE_DAY,
96104
)
97105

98106
# POST /api/orders/

cdk/my_service/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SERVICE_ROLE_ARN = 'ServiceRoleArn'
22
LAMBDA_BASIC_EXECUTION_ROLE = 'AWSLambdaBasicExecutionRole'
33
SERVICE_ROLE = 'ServiceRole'
4+
CREATE_LAMBDA = 'CreateOrder'
45
TABLE_NAME = 'orders'
56
TABLE_NAME_OUTPUT = 'DbOutput'
67
APIGATEWAY = 'Apigateway'

0 commit comments

Comments
 (0)