AWS: Delete lambda layer still retains layer version history
Asked Answered
G

5

12

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?

Gladisgladney answered 24/3, 2020 at 3:56 Comment(0)
A
6

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.

Azrael answered 15/4, 2020 at 11:49 Comment(0)
F
3

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.

Falange answered 25/3, 2020 at 5:53 Comment(0)
H
2

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...

Hara answered 8/4, 2020 at 14:33 Comment(0)
S
2

I am facing the same issue, As there was no aws-cli command to delete the layer itself,I had delete all versions of my lambda-layer using:

aws lambda delete-layer-version --layer-name test_layer --version-number 1

After deleting all versions of the layer, the layer was not showing in aws lambda layers page,So I thought its successfully deleted.

But to my surprise,AWS stills keeps the data about our deleted layers(at-least the last version for sure), when you try create a lambda layer with your previous deleted lambda name using aws gui or cli, the version will not start from 1, instead it starts from last_version of assumed to be deleted layer.

Saporous answered 11/12, 2020 at 14:56 Comment(0)
L
0

https://docs.aws.amazon.com/lambda/latest/dg/creating-deleting-layers.html

When you delete a layer version, you can no longer configure a Lambda function to use it. However, any function that already uses the version continues to have access to it. Also, Lambda never reuses version numbers for a layer name.

In order to do so AWS needs to keep some (internal) memory of the "deleted" layer (versions). AFAIK there is no way to remove these references.

Literalism answered 6/6 at 13:36 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Refutative

© 2022 - 2024 — McMap. All rights reserved.