-
Notifications
You must be signed in to change notification settings - Fork 3
Script: delete_lc
Bruno Galindro da Costa edited this page May 27, 2015
·
3 revisions
Use this script to delete Launch Configurations and associated resources (ec2 images and snapshots) in batch mode
usage: delete_lc [-h]
[-r {us-east-1,cn-north-1,ap-northeast-1,eu-west-1,ap-southeast-1,ap-southeast-2,us-west-2,us-gov-west-1,us-west-1,eu-central-1,sa-east-1}]
[-c CONFIG] [-l LAUNCHCONFIG [LAUNCHCONFIG ...]]
[-L LAUNCHCONFIGREGEXP] [-d] [-s] [-y]
[-o quantity days/hours]
[-a ASSOCIATEDIMAGES [ASSOCIATEDIMAGES ...]]
Delete autoscaling launch configuration
optional arguments:
-h, --help show this help message and exit
-r {us-east-1,cn-north-1,ap-northeast-1,eu-west-1,ap-southeast-1,ap-southeast-2,us-west-2,us-gov-west-1,us-west-1,eu-central-1,sa-east-1}, --region {us-east-1,cn-north-1,ap-northeast-1,eu-west-1,ap-southeast-1,ap-southeast-2,us-west-2,us-gov-west-1,us-west-1,eu-central-1,sa-east-1}
AWS Region
-c CONFIG, --config CONFIG
Config file
-l LAUNCHCONFIG [LAUNCHCONFIG ...], --launchconfig LAUNCHCONFIG [LAUNCHCONFIG ...]
Launch configuration name(s)
-L LAUNCHCONFIGREGEXP, --launchconfigregexp LAUNCHCONFIGREGEXP
Launch configuration regexp
-d, --deleteami Delete AMI associated to launch configuration(s)
-s, --deletesnapshots
Delete snapshots associated to the image(s)
-y, --yes Delete launch configuration(s) without prompt
-o quantity days/hours, --olderthan quantity days/hours
Get launch configuration(s) older than x days/hours
-a ASSOCIATEDIMAGES [ASSOCIATEDIMAGES ...], --associatedimages ASSOCIATEDIMAGES [ASSOCIATEDIMAGES ...]
Get launch configuration(s) associated with this/these
image(s)
- -c/--config: The config file is used only to control logging behaviour.
- -r/--region: The region to search for launch configurations. Default region is set on galintools.json
- -l/--launchconfig: List of launch configurations to use. If isn't used, ALL launch configurations will be marked for deletion
- -L/--launchconfigregexp: Regexp for use in launch configuration's search
- -d/--deleteami: You could choose to delete the ec2 image associated with the launch configuration. Just use this parameter for that.
- -s/--deletesnapshots: You could choose to delete the snapshots of the ec2 image associated with the launch configuration. Just use this parameter for that. This argument needs argument -d/--deleteami.
- -y/--yes: Delete launch configuration(s) without prompt
- -o/--olderthan: Delete launch configuration(s) older than x days/hours. Example: 7 days / 2 hours / 10 days
- -a/--associatedimages: Search for launch configurations associated with these image ids.
- Delete launch configurations
$ delete_lc -l launch_config_webserver_20150305 launch_config_database_20150305
- Delete launch configuration and delete associated ec2 images
$ delete_lc -l launch_config_webserver_20150305 -d
- Delete launch configurations and delete associated ec2 images and snapshots
$ delete_lc -l launch_config_webserver_20150305 launch_config_database_20150305 -d -s
- Delete launch configurations older than 3 days and delete associated ec2 images and snapshots
$ delete_lc -o 3 days -d -s
- Delete launch configurations associated with this ec2 image id, that are older than 3 days and delete associated ec2 images and snapshots
$ delete_lc -o 3 days -d -s -a ami-xxxxxx
- Delete launch configurations older than 3 days and delete associated ec2 images and snapshots and search for launch configurations where name matches the regexp '^LC-'
$ delete_lc -o 3 days -d -s -L '^LC-'