3

Is there a way (using either the AWS CLI or some API) to programmatically remove a layer from an AWS lambda function?

That is, I know I can add or update a layer version by running something like the following

aws lambda update-function-configuration --function-name my-function-name --layer arn:aws:lambda:us-west-2:000000000:layer:layer-name:7

However, this only allows me to add or update the function's configuration. I'd like to programmatically remove the arn:aws:lambda:us-west-2:000000000:layer:layer-name:7 layer from the AWS function named my-function-name

3
  • 1
    aws lambda update-function-configuration doesn't take a single layer. There is no --layer argument, only a --layers argument that takes the full list of layers for the function. If you call this without listing the layer you want to remove, it should remove it. Commented Sep 18, 2021 at 0:40
  • 1
    Just call it aws lambda update-function-configuration --function-name my-function-name --layers Commented Sep 18, 2021 at 5:59
  • Ah, thank you both. An empty --layers option did it. Also, FWIW, the version of the AWS CLI command I have appears to alias the option --layer to --layers. Happy to accept a version of the above as the best answer if someone wants to make it an official answer. Commented Sep 18, 2021 at 19:24

1 Answer 1

4

The values passed to --layers (note: not --layer, which appears to be an alias to the actual option) option replaces your entire layers configuration. This means that, by passing an empty --layers

$ aws lambda update-function-configuration --function-name my-function-name --layers 

you can remove your entire layers configuration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.