Commit e79150fc authored by nimrod's avatar nimrod
Browse files

- Added TODO item of dry_run mode.

- Starting work on command arguments.
parent 1483774b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.
+13 −9
Original line number Diff line number Diff line
@@ -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'],