gorgeous-ram-57119
12/07/2022, 3:13 PMconst scheduleHandler = async (
event: aws.cloudwatch.EventRuleEvent
) => {
// I want to access MY_ENV_VAR here
// but it doesnt show up in the logs
console.log("envs", process.env);
}
const lambdaEnvVars: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}> = {};
lambdaEnvVars["MY_ENV_VAR"] = "my value";
const scheduler: aws.cloudwatch.EventRuleEventSubscription =
aws.cloudwatch.onSchedule(
"schedulePublisher",
"cron(* * * * *)",
scheduleHandler,
{
environment: {
variables: {
MY_ENV_VAR: "my value",
},
},
);
aws lambda update-function-configuration --function-name my-function \
--environment "Variables={BUCKET=my-bucket,KEY=file.txt}"
which i found from the docs
https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.htmlminiature-musician-31262
12/07/2022, 6:39 PMaws.lambda.CallbackFunction
definition, then picked up at runtime by process.env
as you have in your example. The main difference I see is that in my example, I’m defining the callback function as its own resource and setting the environment variables on it, then passing that function to the onSchedule
handler.gorgeous-ram-57119
12/08/2022, 1:45 AM