This Lambda function handles HR-related claim requests. It supports both GET and POST methods and extracts the claim_id from the request.
my-lambda/
├── lambda_function.py
├── README.md
├── trust-policy.json # only if creating a new role
└── function.zip # generated during packaging
zip function.zip lambda_function.pySave the following as trust-policy.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}aws iam create-role \
--role-name lambda-basic-execution \
--assume-role-policy-document file://trust-policy.jsonaws iam attach-role-policy \
--role-name lambda-basic-execution \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole⏳ Wait 10–20 seconds before proceeding to allow IAM changes to propagate.
aws lambda create-function \
--function-name hr-claim-handler \
--runtime python3.11 \
--role arn:aws:iam::<your-account-id>:role/lambda-basic-execution \
--handler lambda_function.lambda_handler \
--zip-file fileb://function.zip🔁 Replace
<your-account-id>with your actual AWS Account ID.
{
"actionGroup": "hr-claims",
"apiPath": "/get-claim",
"httpMethod": "get",
"parameters": [
{
"name": "claim_id",
"value": "ABC123"
}
]
}aws lambda invoke \
--function-name hr-claim-handler \
--payload fileb://event.json \
output.json
cat output.jsonzip function.zip lambda_function.py
aws lambda update-function-code \
--function-name hr-claim-handler \
--zip-file fileb://function.zipaws logs describe-log-groups
aws logs describe-log-streams --log-group-name /aws/lambda/hr-claim-handler--region us-west-2