Skip to content
Snippets Groups Projects
Commit e79150fc authored by nimrod's avatar nimrod
Browse files

- Added TODO item of dry_run mode.

- Starting work on command arguments.
parent 1483774b
No related branches found
No related tags found
No related merge requests found
......@@ -10,4 +10,4 @@ TODO
- Changelog.
- README,
- Testing with different Python versions with tox and flake8.
- Specify number of versions to keep.
- Specify number of versions to keep, dry-run option.
......@@ -6,6 +6,8 @@ from botocore import session
def main():
versions_to_keep = 400
dry_run = False
print('Pruning Elastic Beanstalk versions.')
aws_session = session.get_session()
beanstalk_client = aws_session.create_client('elasticbeanstalk')
......@@ -21,8 +23,10 @@ def main():
lambda x: (not x['VersionLabel'] in active_versions) and
x['Status'] == 'UNPROCESSED', versions)
old_versions = sorted(previous_versions,
key=lambda x: x.get('DateCreated'))[:-400]
key=lambda x:
x.get('DateCreated'))[:-versions_to_keep]
for version in old_versions:
if not dry_run:
response = beanstalk_client.delete_application_version(
ApplicationName=version['ApplicationName'],
VersionLabel=version['VersionLabel'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment