This project contains an example of Lambda function using the parameters module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the documentation.
The example uses the SSM Parameter Store and the Secrets Manager to inject runtime parameters into the application. Have a look at ParametersFunction.java for the full details.
This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting started with SAM in the examples directory
First, hit the URL of the application. You can do this with curl or your browser:
curl https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/params/
You will get your IP address back. The contents of the logs will be more interesting, and show you the values of the parameters injected into the handler:
sam logs --stack-name $MY_STACK_NAME --tail
{
...
"thread": "main",
"level": "INFO",
"loggerName": "org.demo.parameters.ParametersFunction",
"message": "secretjsonobj=MyObject{id=23443, code='hk38543oj24kn796kp67bkb234gkj679l68'}\n",
...
}