Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 905 Bytes

09-pass-environment-variables-to-a-lambda-function-deployed-with-aws-cdk.md

File metadata and controls

22 lines (15 loc) · 905 Bytes

Pass environment variables to a lambda function deployed with AWS CDK

📹 Video

Let's pass an environment variable to our lambda function.

We can do that by adding a prop to our helloLambda function in the stacks file:

const helloLambda = new lambda.Function(this, "HelloLambda", {
    environment: { isProduction: "absolutely not" }
});

Let's console.log our variable:

console.log("isProduction?", process.env.isProduction);

Once you've deployed, you'll be able to see the log. Click on Test in the aws console and checkout the Environment variables.

Environment variable Images