You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose Environment variables in ILambdaContext #11
I was actually thinking of giving it a try myself but I couldn't find any concrete implementation but the one in the Amazon.Lambda.TestUtilities package.
@PavelSafronov I think the point he mention is, Custom Env var that could be set at lambda function. It could be a long list of keyvalue. And whenever we want to edit that list we need to get the whole list without reserved and system env variable
In my case I have lambda cron update everyday. I use environment variable to count number of day it was updated. I need to call GetFunctionConfiguration to get env list of current function, then update the day, and call SetFunctionConfiguration to set it back
If we expose those env in context object it would be easier to access and set, without get
But
@Kralizek It sadly that the core system of lambda does not give that in any language. Not in nodejs or java. We need AWS team to update the system before we could write library to support it
I don't understand why this has to be part of the SDK. If you really want it, just make your own class that wraps System.Environment.GetEnvironmentVariables() and inject it in your constructor yourself.
@Kralizek I used to think like you until I had found that there are EnvironmentVariables of system itself that I don't set it by myself and it hard to exclude all those
So the best solution for me is using lambda.GetFunctionConfiguration().Environment.Variables
@Thaina it sounds like you are asking for the executing Lambda function to have a quick way to change the environment variables set in the Lambda function configuration. That brings in a host of concurrency questions and the service IAM role is likely not going to have permissions to modify the function's configuration.
@normj It not only for change but we could set our own env variable in a way that can be iterate. To iterate all EnvVariable directly and exclude system keyword is prone to error
And I was set role of my lambda function to have lambda invoke permission. So it can change its own env variable programmatically when needed
I don't think it againts concurrency. Because changing env variable of lambda not affect current call. It effect the next call. It more like parameter of recursive function
In my perspective. Env Variable is like a parameter of Main function
I see where you are going with this but it is beyond the scope of what we can do for the .NET Core tooling. You are looking for a Lambda service change that affects all runtimes. For that type of request I'd suggest going to the Lambda forums, https://forums.aws.amazon.com/forum.jspa?forumID=186.
Activity
Kralizek commentedon Dec 12, 2016
I was actually thinking of giving it a try myself but I couldn't find any concrete implementation but the one in the
Amazon.Lambda.TestUtilitiespackage.Am I missing something?
PavelSafronov commentedon Dec 12, 2016
Can you provide a list of the environment variables you are looking for? Some of these may already be exposed on ILambdaContext.
Kralizek commentedon Dec 12, 2016
Mostly the custom ones you use to configure the Lambda.
Kralizek commentedon Jan 11, 2017
Any comment about this suggestion? Also, is there any way I can contribute?
Thaina commentedon Jan 14, 2017
@PavelSafronov I think the point he mention is, Custom Env var that could be set at lambda function. It could be a long list of keyvalue. And whenever we want to edit that list we need to get the whole list without reserved and system env variable
In my case I have lambda cron update everyday. I use environment variable to count number of day it was updated. I need to call
GetFunctionConfigurationto get env list of current function, then update the day, and callSetFunctionConfigurationto set it backIf we expose those env in context object it would be easier to access and set, without get
But
@Kralizek It sadly that the core system of lambda does not give that in any language. Not in nodejs or java. We need AWS team to update the system before we could write library to support it
Kralizek commentedon Jan 16, 2017
Wouldn't be easy to fix for .NET?
and, in the concrete class implementing ILambdaContext, simply add
public IDictionary EnvironmentVariables => System.Environment.GetEnvironmentVariables();if you want to be fancy, you can cast that
IDictionaryinto aIDictionary<string, string>adamhathcock commentedon Jan 16, 2017
I don't understand why this has to be part of the SDK. If you really want it, just make your own class that wraps
System.Environment.GetEnvironmentVariables()and inject it in your constructor yourself.Thaina commentedon Jan 16, 2017
@Kralizek I used to think like you until I had found that there are EnvironmentVariables of system itself that I don't set it by myself and it hard to exclude all those
So the best solution for me is using
lambda.GetFunctionConfiguration().Environment.Variablesnormj commentedon Jan 17, 2017
@Thaina it sounds like you are asking for the executing Lambda function to have a quick way to change the environment variables set in the Lambda function configuration. That brings in a host of concurrency questions and the service IAM role is likely not going to have permissions to modify the function's configuration.
Thaina commentedon Jan 17, 2017
@normj It not only for change but we could set our own env variable in a way that can be iterate. To iterate all EnvVariable directly and exclude system keyword is prone to error
And I was set role of my lambda function to have lambda invoke permission. So it can change its own env variable programmatically when needed
I don't think it againts concurrency. Because changing env variable of lambda not affect current call. It effect the next call. It more like parameter of recursive function
In my perspective. Env Variable is like a parameter of
Mainfunctionnormj commentedon Jan 26, 2017
I see where you are going with this but it is beyond the scope of what we can do for the .NET Core tooling. You are looking for a Lambda service change that affects all runtimes. For that type of request I'd suggest going to the Lambda forums, https://forums.aws.amazon.com/forum.jspa?forumID=186.