Created
January 26, 2020 08:05
-
-
Save elviswolcott/01b9c1115195060e6722a03b7804b6ff to your computer and use it in GitHub Desktop.
Delete all Lambda layer versions across all regions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layer=$1 | |
get_regions () { | |
echo $(aws ssm get-parameters-by-path --region "us-east-1" --path /aws/service/global-infrastructure/services/lambda/regions --query 'Parameters[].Value' --output text | tr '[:blank:]' '\n' | grep -v -e ^cn- -e ^us-gov- | sort -r) | |
} | |
regions=$(get_regions) | |
get_versions () { | |
echo $(aws lambda list-layer-versions --layer-name "$layer" --region "$region" --output text --query LayerVersions[].Version | tr '[:blank:]' '\n') | |
} | |
for region in $regions; | |
do | |
versions=$(get_versions "$region") | |
for version in $versions; | |
do | |
echo "deleting arn:aws:lambda:$region:*:layer:$layer:$version" | |
aws lambda delete-layer-version --region "$region" --layer-name "$layer" --version "$version" > /dev/null | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hacksonX is correct the argument is
--version-number
not--version