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
aws lambda update-function-configurationdoesn't take a single layer. There is no--layerargument, only a--layersargument 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.aws lambda update-function-configuration --function-name my-function-name --layers--layersoption did it. Also, FWIW, the version of the AWS CLI command I have appears to alias the option--layerto--layers. Happy to accept a version of the above as the best answer if someone wants to make it an official answer.