Hello,
I am using bitbucket pipline to deploy my lambdas. For now everything is fine, except for deploying layers.
in 2018 aws introduced layer for lambdas, mainly used to share a common code (conf, models, ...) between lambdas and also to create runtime environement for not supported langages.
I have lambdas to manage users (nodejs + mongodb) : create user, login, activate user, update, ...
these lambdas are sharing the same model and configuration. So, I would like to avoid duplicating code, so I thought about creating layer.
My problem is:
1/ How can I do to update my layer when I deploy my lambda (specify latest layer) ?
I am using (AWS Lambda deploy : v0.3.2maintained by Atlassian)
Thank you in advance for your help.
Best regards
Adel MANI
I tried the same config but failed. just removed the account number for security.
here is my config file
----------------------------
{"Layers":
[
{ "Arn": "arn:aws:lambda:eu-west-1:xxxxxxxxxxx
:layer:ap-mail-node-pgpool-1:22", "CodeSize": 229879 }
]
}
---------------------------------------
function update part works just file but while updating config it fails
here is the error log
INFO: Updating Lambda function configuration.
aws lambda update-function-configuration --function-name ap-mail-ds1-scs-1 --cli-input-json {"Layers":
[
{ "Arn": "arn:aws:lambda:eu-west-1:xxxxxxxxxxx:layer:ap-mail-node-pgpool-1:22", "CodeSize": 229879 }
]
}
Parameter validation failed:
Invalid type for parameter Layers[0], value: {u'CodeSize': 229879, u'Arn': u'arn:aws:lambda:eu-west-1:xxxxxxxxxxx:layer:ap-mail-node-pgpool-1:22'}, type: <type 'dict'>, valid types: <type 'basestring'>
✖ Failed to update Lambda function configuration.
Hi @MANI Adel . If you wan't to just add an existing layer to your lambda function, you should create a function configuration json file an reference it in the FUNCTION_CONFIGURATION variable. The pipe will update the function configuration to include the layers.
Example function-configuration.json
{"Layers":
[
{ "Arn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:3", "CodeSize": 169 },
{ "Arn": "arn:aws:lambda:us-east-2:210987654321:layer:their-layer:2", "CodeSize": 169 }
]
}
Example pipe configuration:
script: - pipe: atlassian/aws-lambda-deploy:0.4.1 variables: AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION FUNCTION_NAME: 'my-lambda-function' COMMAND: 'update' ZIP_FILE: 'my-function-code.zip'
FUNCTION_CONFIGURATION: 'function-configuration.json'
Note, that updating or creating a function layer is not supported in the pipe yet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alexander Zhukov,
Thank you for replying my request.
My question was not clair, I was looking for the way how to deploy an update or publish of layer (publish-layer-version).
I solved this problem by creating aws_nodejs docker image and lauching the the following CLI command :
script:
- aws configure set default.region $AWS_DEFAULT_REGION
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws lambda publish-layer-version --layer-name Layer_01 --compatible-runtimes nodejs nodejs10.x nodejs8.10 --zip-file fileb://nodejs.zip --region $AWS_DEFAULT_REGION
Thank you very much for taking in consideration my request.
Best regards
Adel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.