Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support to delete old versions when successful deployment #7414

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Formatting
driverpt committed Jan 30, 2025
commit 94bc1e4f63c98640b8e8dc2d1c7434d531901f45
26 changes: 14 additions & 12 deletions samcli/lib/sync/flows/alias_version_sync_flow.py
Original file line number Diff line number Diff line change
@@ -27,15 +27,15 @@ class AliasVersionSyncFlow(SyncFlow):
_lambda_client: Any

def __init__(
self,
function_identifier: str,
alias_name: str,
delete_old_alias: bool,
build_context: "BuildContext",
deploy_context: "DeployContext",
sync_context: "SyncContext",
physical_id_mapping: Dict[str, str],
stacks: Optional[List[Stack]] = None,
self,
function_identifier: str,
alias_name: str,
delete_old_alias: bool,
build_context: "BuildContext",
deploy_context: "DeployContext",
sync_context: "SyncContext",
physical_id_mapping: Dict[str, str],
stacks: Optional[List[Stack]] = None,
):
"""
Parameters
@@ -118,8 +118,10 @@ def _equality_keys(self) -> Any:

def _get_version_alias_if_exists(self) -> Optional[str]:
try:
return str(self._lambda_client.get_alias(FunctionName=self.get_physical_id(self._function_identifier),
Name=self._alias_name)
.get("FunctionVersion"))
return str(
self._lambda_client.get_alias(
FunctionName=self.get_physical_id(self._function_identifier), Name=self._alias_name
).get("FunctionVersion")
)
except self._lambda_client.exceptions.ResourceNotFoundException:
return None
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@


class TestAliasVersionSyncFlow(TestCase):
def create_sync_flow(self, delete_old_alias = False):
def create_sync_flow(self, delete_old_alias=False):
sync_flow = AliasVersionSyncFlow(
"Function1",
"Alias1",