Skip to content

lambda-cmd

create execute role

save code

wget -O index.js 'https://raw.githubusercontent.com/panlm/aws-eks-example/main/lambda/kinesis-firehose-cloudwatch-logs-processor'
zip function.zip index.js

create lambda

role_arn=$(aws iam get-role --role-name ${role_name} |jq -r '.Role.Arn')
aws lambda create-function \
--function-name cwl-s3-${role_name} \
--timeout 60 \
--runtime 'nodejs14.x' \
--role ${role_arn} \
--zip-file fileb://function.zip \
--handler index.handler

add-layer-to-lambda-

  • upload zip package from mac to lambda, seems works
mkdir -p $$/python/lib/python3.11/site-packages
pip install flatten_json -t $$/python/lib/python3.11/site-packages
cd $$
zip -r package.zip ./python
  • push layer version
    aws lambda publish-layer-version --layer-name layer_flatten_json --description "flatten_json" --zip-file fileb://package.zip --compatible-runtimes python3.8
    layer_arn=$(aws lambda list-layer-versions --layer-name layer_flatten_json \
    --query 'LayerVersions[0].LayerVersionArn' --output text)
    
    aws lambda update-function-configuration --function-name ${lambda_name} \
    --layers ${layer_arn}