Instructor: 0:00 With CDK, we can also pass in environment variables to our lambda functions. They can behave differently depending on those values.
0:07 In order to add an environment variable to this hello lambda function, we have to add an additional prop. This prop is going to be environment. We can see that this prop takes a key value pair. In other words, an object.
0:18 By default, there are no environment variables provided to a lambda function, so I'm going to do environment. This is going to be isProduction. I'm going to set it to a string, "absolutely not" because we are just experimenting over here.
0:30 Right now, if I go to our lambda function, I can go ahead and console log isProduction. I'm going to console log process.env isProduction. Once we save that, go back to our stock and now it's ready to be deployed.
0:46 Now we can open up our terminal and then run CDK deploy, in order to deploy this change to AWS. After a successful deployment, we can see that the line that we've added over here is also present in the AWS console.
0:57 If you scroll down a bit, we are going to be able to see this environment variable. The key is "is production" and the value is "absolutely not." If we call this function using a test event, if I click over here, after expanding that, we are going to be able to see over here that our environment variable has been logged out. So "is production," "absolutely not."