I have a Lambda in C# and I'm trying to access parameters stored in the ECQ Parameter Store. The parameters are stored as a String Value.
My Lambda is configured to use an existing role. In IAM, I've assigned the following policies to the role:
The Lambda runs inside of our VPC and if the parameter value is hard-coded it executes successfully.
My code to get the parameter is:
var client = new AmazonSimpleSystemsManagementClient(RegionEndpoint.APSoutheast2);
var request = new GetParametersRequest
{
Names = new List<string>{ "ParameterName" }
};
var response = client.GetParametersAsync(request).Result;
var value = response.Parameters.Single().Value;
I have logging before and after the call to GetParametersAsync and it doesn't get to the logging after the call.
What do I need to do to be able to get the parameter value from the Lambda?
The issue was caused by the Lambda running inside of our VPC. Accessing SSM is done via the internet so I had to configure a NAT Gateway to give the Lambda access to the internet.
Once this was done, the Lambda could access the SSM parameters successfully.
You should have something similar to:
public async Task<Response> ProcessS3ImageResizeAsync(SimpleS3Event input)
{
var response = await client.DoAsyncWork(input);
return response;
}
In async call the response is not immediate, thus you need to wait before.
More information:
[1] http://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html#dot-net-async
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With