Skip to content

Lambda Specific Configuration does not work with CDK #1998

@hnishi

Description

@hnishi

I am using Chalice with CDK to create a REST API and a scheduled lambda function (for a batch job).

I want to specify the configuration for the scheduled lambda function.

@app.schedule(Cron(0, 16, "L", "*", "?", "*"))
def foo(event, context):
    print("hello world")

In the CDK file, the following configuration is used.

class ChaliceApp(cdk.Stack):
    def __init__(self, scope, id, **kwargs):
        super().__init__(scope, id, **kwargs)
        self.dynamodb_table = self._create_ddb_table()
        self.chalice = Chalice(
            self,
            "ChaliceApp",
            source_dir=RUNTIME_SOURCE_DIR,
            stage_config={
                "environment_variables": {
                    "APP_TABLE_NAME": self.dynamodb_table.table_name
                },
                "lambda_functions": {
                    "foo": {
                        "lambda_timeout": 600,
                        "lambda_memory_size": 256,
                        "environment_variables": {"HELLO": "world"},
                    }
                },
            },
        )
        self.dynamodb_table.grant_read_write_data(self.chalice.get_role("DefaultRole"))

However, after deploying the application with cdk deploy, the scheduled lambda function is created with the default timeout (60 sec) and memory size (128 MB).

I think the Lambda Specific Configuration does not work with CDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions