[Python] How to create Lambda versions with different EnvironmentOptions using CDK

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have created my Lambda function as part of my CDK stack in typescript

    const dummy_lambda = new Function(this, 'dummy-lambda', {
    functionName: 'dummy-lambda',
    code: Code.fromAsset('../dummy-lambda/src'),
    handler: 'index.lambda_handler',
    timeout: Duration.seconds(900),
    runtime: Runtime.PYTHON_3_8,
    role: snapshotRole,
    environment : {
    'region': props.env.region,
    'utility': props.Utility,
    'siteUrl' : props.siteUrl
    }
    });


    I want to create different versions of this lambda to be able to run it for different applications by changing the siteUrl and Utility EnvironmentOptions. However, Version doesn't take environment as props.

    const dummy_ver_ci =new Version(this, 'ci-dummy', {
    lambda: dummy_lambda,
    description: 'Version for CI app'
    });


    How can I create different versions and pass different environment values to each version.

    Continue reading...

Compartilhe esta Página