Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS: Delete lambda layer still retains layer version history

I am deploying a AWS Lambda layer using aws cli:

aws lambda publish-layer-version --layer-name my_layer --zip-file fileb://my_layer.zip

I delete it using

VERSION=$(aws lambda list-layer-versions --layer-name my_layer | jq '.LayerVersions[0].Version'
aws lambda delete-layer-version --layer-name my_layer --version-number $VERSION

Deletes successfully, ensured no other version of the layer exists.

aws lambda list-layer-versions --layer-name my_layer
>
{
    "LayerVersions": []
}

Upon next publishing of the layer, it still retains history of previous version. From what I read if no layer version exists and no reference exists, the version history should be gone, but I don't see that. Anybody have a solution to HARD delete the layer with its version?

like image 616
cloud jockey Avatar asked Mar 24 '20 03:03

cloud jockey


3 Answers

I have the same problem. What I'm trying to achieve is to "reset" the version count to 1 in order to match code versioning and tags on my repo. Currently, the only way I found is to publish a new layer with a new name.

I think AWS Lambda product lacks of features that help (semantic) versioning.

like image 157
Federico Boschini Avatar answered Sep 17 '22 21:09

Federico Boschini


Currently there's no way to do this. Layer Versions are immutable, they cannot be updated or modified, you can only delete and publish new layer versions. Once a layer version is 'stamped' -- there is no way (AFAIK) that you can go back and get back that layer version.

It might be that after a while (weeks...months?) AWS delete it's memory of the layer version, but as it stands, the version number assigned to any deleted layer cannot be assumed by any new layer.

like image 29
keithRozario Avatar answered Sep 21 '22 21:09

keithRozario


I ran into similar problem with layer versions. Do you have suggestions for simple way out instead of writing code to check available versions out there and pick latest one...

like image 25
Sudhir Nallagangu Avatar answered Sep 20 '22 21:09

Sudhir Nallagangu