How to automatically change lambda layer version in zappa_settings.json file while publishing a new lambda layer version?

383 views Asked by At

I have a lambda layer set up, and a shell file that deploys it. I have written github workflows that triggers this shell file whenever there's a change in code in that particular repository. Since a newer version is published, I would like to change the lambda-layer-version to change in zappa-settings.json. Is there a way to automate this, or will I have to manually do it everytime?

Here's my zappa-settings.json file:

{
    "dev": {
        "app_function": "app.app",
        "profile_name": "zappa-dev",
        "project_name": "zappa-app",
        "runtime": "python3.8",
        "s3_bucket": "zappa-app-dev",
        "aws_region": "ap-south-1",
        "slim_handler": true,
        "layers": ["arn:aws:lambda:ap-south-1:594519763223:layer:testapp-lambda-layer:2"]
    }
}

Over here, I would like to change '2' to the latest version. I have tried using $LATEST, but it throws regex error.

1

There are 1 answers

0
user3014044 On

It seems zappa code in https://github.com/zappa/Zappa passes this value directly to boto3 client's create_function method. So the issue is with specifying latest layer version in AWS itself.

It can be manually updated by fetching list of versions and selecting the first result, like here: https://stackoverflow.com/a/55752188/3014044