aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

Can the Lambda Test Tool retrieve a Lambda function's environment variables?

Open TrongTheAlpaca opened this issue 4 years ago • 2 comments

Description

Is it possible to retrieve a specific Lambda function's configurations/environment variables using the Lambda Test Tool? In other words: Can I debug locally with configurations from "remote" AWS using my IAM profile?

Note: I know you can have environment variables defined locally, but I was hoping if there existed an alternative where you could skip having any definitions locally?

What I thought would work

Remote

I have an existing Lambda Function named theFunctionName with the following environment variables: image

Locally

Given the file: aws-lambda-tools-defaults.json

{
    // Removed some lines for brevity
    "profile": "IAM-tester",
    "region": "eu-west-1",
    "package-type": "image",
    "function-name": "theFunctionName",
}

In the tool, apply the above configuration: image

I expected the Lambda Test Tool to execute the code with the selected Lambda function's (here: theFunctionName) configuration and environment variables (i.e. finding the above environment variables secret_1, secret_2 and secret_3. This is not the case.

Is this behaviour not possible / have I set it up incorrectly?

Thanks!


This is a :question: general question

TrongTheAlpaca avatar Dec 20 '21 12:12 TrongTheAlpaca

Hi @TrongTheAlpaca, The Lambda Test Tool is a tool that can be used to load a .NET Core Lambda project and execute the selected code inside an emulated Lambda environment.

Currently, as you described earlier, it can have environment variables defined locally for setting up configurations but does not have the functionality to execute code using the lambda function configurations present in AWS console automatically.

If you prefer and would like to see this functionality, I could mark this as a feature request to be analyzed for implementation in the future.

Hope this helps!

aaoswal avatar Dec 21 '21 20:12 aaoswal

I see, yeah I would love to see this as a feature! Would you mark it as Feature Request for me? 😀

TrongTheAlpaca avatar Dec 22 '21 09:12 TrongTheAlpaca

@TrongTheAlpaca Good morning. I was going through the backlog and came across this issue. Just wanted to re-confirm, does your case involves Lambda Test Tool probe actual deployed function for the environment variables? If yes, then curious what happens in a scenario where the function is not actually deployed; does it follows the default path, i.e., not to probe for environment variables? You may also refer article https://blog.tonysneed.com/2018/12/16/add-net-core-di-and-config-goodness-to-aws-lambda-functions/ on how to define environment variables at development time. Lambda Test Tool is designed to test Lambda functions in local environment, so not sure if it would be feasible to to probe actual deployed Lambda function for environment variables. Please review.

Thanks, Ashish

ashishdhingra avatar Dec 23 '22 18:12 ashishdhingra

This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

github-actions[bot] avatar Dec 29 '22 00:12 github-actions[bot]