Skip to content

Commit

Permalink
fixup! Fix: Race between layer and Lambda update (#5927)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirho-ucsc committed Aug 21, 2024
1 parent 8e9ab6a commit c04e0bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

def main():
require(config.terraform_component == '',
'Cannot be run with a terraform component',
'This script cannot be run with a Terraform component selected',
config.terraform_component)
Lambdas().delete_lambda_versions()
Lambdas().delete_stale_function_versions()


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions src/azul/lambdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ def reset_lambda_roles(self):
else:
break

def delete_lambda_versions(self):
def delete_stale_function_versions(self):
"""
Delete all but the latest published version of every AWS Lambda function
in the current deployment.
"""
log.info('Deleting old published versions of AWS Lambda functions')
log.info('Deleting stale versions of AWS Lambda functions')
for function in self.list_deployment_lambdas():
if function.version == '$LATEST':
log.info('Skipping latest version %r', function.name)
else:
log.info('Deleting published version %r of %r', function.version, function.name)
log.info('Deleting version %r of %r', function.version, function.name)
self._lambda.delete_function(FunctionName=function.name,
Qualifier=function.version)
10 changes: 5 additions & 5 deletions terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ import_resources: rename_resources
plan: import_resources
terraform plan

.PHONY: delete_lambda_versions
delete_lambda_versions: import_resources check_python
python $(project_root)/scripts/delete_lambda_versions.py
.PHONY: delete_stale_function_versions
delete_stale_function_versions: import_resources check_python
python $(project_root)/scripts/delete_stale_function_versions.py

.PHONY: apply
apply: delete_lambda_versions
apply: delete_stale_function_versions
ifeq ($(AZUL_PRIVATE_API),1)
# For private API we need the VPC endpoints to be created first so that the
# aws_lb_target_group_attachment can iterate over the network_interface_ids.
Expand All @@ -57,7 +57,7 @@ endif
terraform apply

.PHONY: auto_apply
auto_apply: delete_lambda_versions
auto_apply: delete_stale_function_versions
ifeq ($(AZUL_PRIVATE_API),1)
# See `apply` above
terraform apply -auto-approve -target aws_vpc_endpoint.indexer -target aws_vpc_endpoint.service
Expand Down

0 comments on commit c04e0bc

Please sign in to comment.