Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PowertoolsStack(Stack):
def __init__(self, scope: Construct, construct_id: str, environment: str = "dev", **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

self.env = environment
self.deploy_environment = environment

# Shared Powertools Layer (using public layer)
self.powertools_layer = self._create_powertools_layer()
Expand Down Expand Up @@ -54,17 +54,17 @@ def _create_dynamodb_table(self) -> dynamodb.Table:
return dynamodb.Table(
self,
"DataTable",
table_name=f"powertools-{self.env}-data",
table_name=f"powertools-{self.deploy_environment}-data",
partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
billing_mode=dynamodb.BillingMode.PAY_PER_REQUEST,
removal_policy=RemovalPolicy.DESTROY if self.env != "prod" else RemovalPolicy.RETAIN,
removal_policy=RemovalPolicy.DESTROY if self.deploy_environment != "prod" else RemovalPolicy.RETAIN,
)

def _create_sqs_queue(self) -> sqs.Queue:
return sqs.Queue(
self,
"WorkerQueue",
queue_name=f"powertools-{self.env}-worker",
queue_name=f"powertools-{self.deploy_environment}-worker",
visibility_timeout=Duration.seconds(180),
)

Expand All @@ -77,12 +77,12 @@ def _create_api_function(self) -> _lambda.Function:
code=_lambda.Code.from_asset("src/app"),
layers=[self.powertools_layer],
timeout=Duration.seconds(30),
memory_size=512 if self.env == "prod" else 256,
memory_size=512 if self.deploy_environment == "prod" else 256,
environment={
"ENVIRONMENT": self.env,
"POWERTOOLS_SERVICE_NAME": f"app-{self.env}",
"POWERTOOLS_METRICS_NAMESPACE": f"MyApp/{self.env}",
"POWERTOOLS_LOG_LEVEL": "INFO" if self.env == "prod" else "DEBUG",
"ENVIRONMENT": self.deploy_environment,
"POWERTOOLS_SERVICE_NAME": f"app-{self.deploy_environment}",
"POWERTOOLS_METRICS_NAMESPACE": f"MyApp/{self.deploy_environment}",
"POWERTOOLS_LOG_LEVEL": "INFO" if self.deploy_environment == "prod" else "DEBUG",
"TABLE_NAME": self.table.table_name,
"QUEUE_URL": self.queue.queue_url,
},
Expand All @@ -103,12 +103,12 @@ def _create_worker_function(self) -> _lambda.Function:
code=_lambda.Code.from_asset("src/worker"),
layers=[self.powertools_layer],
timeout=Duration.seconds(120),
memory_size=1024 if self.env == "prod" else 512,
memory_size=1024 if self.deploy_environment == "prod" else 512,
environment={
"ENVIRONMENT": self.env,
"POWERTOOLS_SERVICE_NAME": f"worker-{self.env}",
"POWERTOOLS_METRICS_NAMESPACE": f"MyApp/{self.env}",
"POWERTOOLS_LOG_LEVEL": "INFO" if self.env == "prod" else "DEBUG",
"ENVIRONMENT": self.deploy_environment,
"POWERTOOLS_SERVICE_NAME": f"worker-{self.deploy_environment}",
"POWERTOOLS_METRICS_NAMESPACE": f"MyApp/{self.deploy_environment}",
"POWERTOOLS_LOG_LEVEL": "INFO" if self.deploy_environment == "prod" else "DEBUG",
"TABLE_NAME": self.table.table_name,
},
)
Expand All @@ -131,8 +131,8 @@ def _create_api_gateway(self) -> apigateway.RestApi:
api = apigateway.RestApi(
self,
"ApiGateway",
rest_api_name=f"Powertools API - {self.env}",
description=f"API for {self.env} environment",
rest_api_name=f"Powertools API - {self.deploy_environment}",
description=f"API for {self.deploy_environment} environment",
)

integration = apigateway.LambdaIntegration(self.api_function)
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.