I have a Lambda function written in dotnet 6 that connects to RDS and inserts some data. I want to have the connection parameters (db host, db password, db name) stored in SSM ParameterStore instead of hardcoded in the function.
I have found Amazon.Extensions.Configuration.SystemsManager which seems to be able to add the SSM parameters as a dotnet Configuration source.
If I add this to the constructor of the base class of the handlers:
public class Function
{
private IConfiguration _configuration = default!;
public Function() {
LambdaLogger.Log("START CONSTRUCTOR");
_configuration = new ConfigurationBuilder()
.AddSystemsManager("/")
.Build();
LambdaLogger.Log("END CONSTRUCTOR");
}
//Function handlers, etc.
}
the lambda function times out.
If I change that to
public class Function
{
private IConfiguration _configuration = default!;
public Function() {
LambdaLogger.Log("START CONSTRUCTOR");
_configuration = new ConfigurationBuilder()
.Build();
LambdaLogger.Log("END CONSTRUCTOR");
}
//Function handlers, etc.
}
the lambda function works, so it is the AddSystemsManager()
call which is timing out for some reason. I have added to the lambda execution role the policies arn:aws:iam::aws:policy/AmazonSSMFullAccess
and arn:aws:iam::aws:policy/AWSKeyManagementServicePowerUser
(for SecureString)
So, what am I doing wrong or what else do I need to check to access SSM from a dotnet 6 lambda?
Also, if you can't suggest about this specific problem, can you suggest a path you know works to get centralized configuration onto dotnet 6 lambdas?