I have a .NET Lambda function written in C# that is implemented as a .NET Minimal API according to the guidance provided here. To define AWS resources, I am utilizing CDK (TypeScript).
Within my build pipeline, there is shell scripting involved to supply a parameter for stage definition (e.g. dev vs. qa vs. beta vs. prod) with the command:
cdk synth -c "stage=${StageName}"
When accessing this variable in my CDK code, I use the following syntax:
const stage = this.node.tryGetContext('stage');
This variable determines which environment-specific settings from cdk.json are used when setting up the stack (such as endpoints).
My query pertains to passing this variable into the startup logic of the Lambda function. While I can pass it within the body of the function itself as a parameter, I require it to be available in the application's startup logic executed prior to entering the function body (for configuring the appropriate appsettings.{env}.json file).
Can this be achieved through the CDK?