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.py
Save 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.json
aws 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.
event.json{
"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.json
zip function.zip lambda_function.py
aws lambda update-function-code \
--function-name hr-claim-handler \
--zip-file fileb://function.zip
aws logs describe-log-groups
aws logs describe-log-streams --log-group-name /aws/lambda/hr-claim-handler
--region us-west-2
36 commits
Python
100.0%
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.py
Save 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.json
aws 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.
event.json{
"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.json
zip function.zip lambda_function.py
aws lambda update-function-code \
--function-name hr-claim-handler \
--zip-file fileb://function.zip
aws logs describe-log-groups
aws logs describe-log-streams --log-group-name /aws/lambda/hr-claim-handler
--region us-west-2
36 commits
Python
100.0%