-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Race between layer and Lambda update (#5927)
- Loading branch information
1 parent
ab66224
commit d126563
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Delete all published AWS Lambda versions except for "$LATEST" in the current | ||
deployment. | ||
""" | ||
|
||
import logging | ||
|
||
from azul.deployment import ( | ||
aws, | ||
) | ||
from azul.lambdas import ( | ||
Lambdas, | ||
) | ||
from azul.logging import ( | ||
configure_script_logging, | ||
) | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def main(): | ||
lambdas = Lambdas().list_lambdas(deployment_only=True) | ||
for lambda_ in lambdas: | ||
log.info('Fetching the published versions of %s', lambda_.name) | ||
response = aws.lambda_.list_versions_by_function(FunctionName=lambda_.name) | ||
for version in response['Versions']: | ||
version = version['Version'] | ||
if version == '$LATEST': | ||
pass | ||
else: | ||
log.info('Deleting published version %s of %s', version, lambda_.name) | ||
aws.lambda_.delete_function( | ||
FunctionName=lambda_.name, | ||
Qualifier=version | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
configure_script_logging(log) | ||
main() |
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