{ "info": { "author": "Marcos Martinez", "author_email": "frommelmak@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Utilities" ], "description": "[![PyPI](https://img.shields.io/pypi/v/aws-scripts.svg)](https://pypi.org/project/aws-scripts/)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)\n\naws-scripts\n===========\n\nHere you will find some useful AWS scripts I use from time to time.\n\nAll the scripts relies on [Boto](http://aws.amazon.com/sdkforpython/), a Python package that provides interfaces to Amazon Web Services.\n\nSo, to use these scripts, you need to install Boto and provide your AWS credentinals:\n\nTo install aws-scripts and all the required Python packages just type:\n\n```\npip install aws-scripts \n```\n\nIf dependencies are already satisfied, nothing will be installed.\n\nTo provide your AWS credentials use the boto/boto3 config file `~/.aws/credentials`:\n\n``` ini\n[default]\naws_access_key_id = \naws_secret_access_key = \nregion=xx-xxxx-x\n```\n\n> Note that you can use the environment variable: ```AWS_DEFAULT_REGION=xx-xxxx-x``` to override the default region on the config file.\n> In the ec2-instances.py script you can also use the ```--region``` option for the same purpose \n\nec2-instances.py\n----------------\n\nList the EC2 instances including the Name Tag, IP, type, zone, vpc, ID and the status.\n\nYou can filter the result by name, type and/or status. Or you can provide a list of instance IDs instead.\n\nFinally you can execute remote commands on all the instances returned by the filter or the list.\n\nThe '-h' option shows you how to use the available options.\n\n```\nusage: ec2-instances.py [-h] [-n NAME] [-t TYPE] [-s STATUS]\n [-l ID_LIST [ID_LIST ...]] [-e EXECUTE] [-r REGION]\n [-u USER]\n\noptional arguments:\n -h, --help show this help message and exit\n -n NAME, --name NAME Filter result by name.\n -t TYPE, --type TYPE Filer result by type.\n -s STATUS, --status STATUS\n Filter result by status.\n -l ID_LIST [ID_LIST ...], --id_list ID_LIST [ID_LIST ...]\n Provide a list of InstanceIds.\n -e EXECUTE, --execute EXECUTE\n Execute a command on instances\n -r REGION, --region REGION\n Specify an alternate region to override the one\n defined in the .aws/credentials file\n -u USER, --user USER User to run commands if -e option is used. Ubuntu user\n is used by default\n```\n\nec2-reserved.py\n----------------\n\nLists details of all your Instance Reservations, including a summary of the active reservations by type and size.\n\nThe summary also shows your reserved active capacity after apply the normalization factor. This is useful to compare the reserved capacity with the deployed in production.\n\nYou can also use the option `--create-google-calendar-events` to add the expiration date of the active reservations in your Google Calendar Account.\n\n```\nusage: ec2-reserved.py [-h]\n [-s {payment-pending,active,payment-failed,retired}]\n [--create-google-calendar-events] [-t TYPE]\n\nShow reserved EC2 instances\n\noptional arguments:\n -h, --help show this help message and exit\n -s {payment-pending,active,payment-failed,retired}, --state {payment-pending,active,payment-failed,retired}\n Filer result by reservation state.\n --create-google-calendar-events\n Create events in your Google Calendar, using the\n expiration dates of your active reservations\n -t TYPE, --type TYPE Filer result by instance type.\n```\n\nTo use the Google calendar feature you just have to [enable the calendar API in your Google Account](https://console.developers.google.com) and create a calendar called aws in the [Google Calendar](http://calendar.google.com/). Then create the *OAuth client ID* credentials. Download the credentials file and save it as `client_secret.json` in the aws-scripts folder repo. When you run the script using the `--create-google-calendar-events` option for the first time, a web browser will be opened asking your to login with the Google account you want to use.\n\nThen, whenever you buy new reservations on Amazon Web Services, you can add the new reservations in your calendar by just running the script.\n\nec2-elb.py\n----------\n\nLists all your Elastic Load Balancers and his related instances.\n\n```\nusage: ec2-elb.py [-h]\n\nFor every Elastic Load Balancer list the attached instances\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\nec2-snap-mgmt.py\n----------------\n\nWith this script you can see the relationships between your snapshots and your EBS volumes and AMIs. This allows you to choose the snapshots you don't need to keep in the AWS S3 service.\n\nBy default the script shows all the volumes and AMIs related to each snapshost.\n\nYou you can also show all the snapshots related with each volume. This option is specially usefull when you only want to keep a certain number of snapshots per volume.\n\nFinally, you can show all the snapshots related with each AMI.\n\nThe '-h' option shows you how to use the available options.\n\n```\nusage: ec2-snap-mgmt.py [-h] [-v {orphan,volumes}] owner_id\n\npositional arguments:\n owner_id 12-digit AWS Account Number\n\noptional arguments:\n -h, --help show this help message and exit\n -v {orphan,volumes,images}, --view {orphan,volumes,images}\n Available views: orphan and volumes. Orphan is the\n default one.\n```\n\nThe script doesn't delete anything actually, just shows you the relationship in a tree view.\n\ns3-mongodump.py\n---------------\n\nThis is a tool to make mongodb backups on Amazon s3.\n\nIt uses mongodump to perform a binary backup of your local or remote mongodb instance. The dumped files are compressed in a tarball file and uploaded to a Amazon S3 bucket.\nYou can specify the number of copies to retain in the bucket. The oldest ones will be automatically removed.\n\n```\nusage: s3-mongodump.py [-h] [-u USER] [-p PASSWORD] [-H HOST] [-d DATABASE]\n [-o OUT] [-n NUMBER] -b BUCKET [-P PREFIX]\n\nA tool to make mongodb backups on Amazon s3\n\noptional arguments:\n -h, --help show this help message and exit\n -u USER, --user USER Mongodb user (optional)\n -p PASSWORD, --password PASSWORD\n Mongodb password (optional)\n -H HOST, --host HOST Mongodb host: :.\n -d DATABASE, --database DATABASE\n The database to backup (all if not provided)\n -o OUT, --out OUT The output directory for dumped files\n -n NUMBER, --number NUMBER\n Number of copies to retain in the S3 bucket\n -b BUCKET, --bucket BUCKET\n Amazon s3 bucket.\n -P PREFIX, --prefix PREFIX\n For grouped objects aka s3 folders, provide the prefix\n key\n```\n\nroute53-set-hostname.py\n-----------------------\n\nThis script allows you to automatically set predictable DNS records for instances launched using AWS Auto Scaling. \n\nIt is intended to be executed from the ec2 instance at launch time.\nThe script looks for an available name matching the provided pattern in the DNS zone. Then, it adds this name as a CNAME record in the DNS zone pointing to the EC2 instance public name.\n\n```\nusage: route53-set-hostname.py [-h] --HostedZoneId HOSTEDZONEID --HostStr\n HOSTSTR [--rangeSize RANGESIZE] [--dryrun]\n\nAWS Route53 hostname managment for Autoscaled EC2 Instances\n\noptional arguments:\n -h, --help show this help message and exit\n --HostedZoneId HOSTEDZONEID\n The ID of the hosted zone where the new resource\n record will be added.\n --HostStr HOSTSTR The host string used to build the new name\n --rangeSize RANGESIZE\n The maximun number to be assigned. The first available\n will be used\n --dryrun Shows what is going to be done but doesn't change\n anything actually\n```\n\nExample:\n\n``` bash\nuser@host:~$ ./route53-set-hostname.py --HostedZoneId XXXXXXXXXXXXXX --HostStr websrv --rangeSize 10\n15:41:58 06/09/16: creating CNAME websrv03.example.com. -> ec2-XX-XX-XXX-XX.compute-1.amazonaws.com......INSYNC\n```\n\nroute53-del-hostname.py\n-----------------------\n\nThis script is executed from the ec2 instance at shutdown.\nThe script delete his host record zone from the passed DNS zone identifier.\n\n```\nusage: route53-del-hostname.py [-h] --HostedZoneId HOSTEDZONEID [--dryrun]\n\nAWS Route53 hostname managment for Autoscaled EC2 Instances\n\noptional arguments:\n -h, --help show this help message and exit\n --HostedZoneId HOSTEDZONEID\n The ID of the hosted zone where the new resource\n record will be added.\n --dryrun Shows what is going to be done but doesn't change\n anything actually\n```\n\ns3-download-file.py\n-------------------\n\nThis script just download the requested S3 object.\n\n```\nusage: s3-download-file.py [-h] -b BUCKET -o OBJECTKEY -f FILEPATH\n\nDonwload file from AWS S3\n\noptional arguments:\n -h, --help show this help message and exit\n -b BUCKET, --bucket BUCKET\n The bucket name.\n -o OBJECTKEY, --objectkey OBJECTKEY\n The host string used to build the new name\n -f FILEPATH, --filepath FILEPATH\n The filepath of the file to be saved\n```\n\nlifecycle-hook-worker.py\n------------------------\n\nAs its own name says, this worker is designed to use auto scaling [lifecycle hooks](http://docs.aws.amazon.com/autoscaling/latest/userguide/lifecycle-hooks.html).\n\nThe process looks for incoming messages into the SQS queue asociated with the autoscaling group. Then, when a message comes for the instance, it is consumed and the associated custom action is triggered. Finally, using the lifecyle action token, the worker completes the autoscaling action going on with the launch or ending the instance action.\n\n```\nusage: lifecycle-hook-worker.py [-h] -q QUEUE -s {LAUNCHING,TERMINATING} -g\n GROUP -H HOOKNAME -e EXECUTE [-w WAIT]\n\nSQS Lifecycle hook consumer and trigger\n\noptional arguments:\n -h, --help show this help message and exit\n -q QUEUE, --queue QUEUE\n Queue resource.\n -s {LAUNCHING,TERMINATING}, --state {LAUNCHING,TERMINATING}\n Indicates if the consumer is waiting for LAUNCHING or\n TERMINATING state\n -g GROUP, --group GROUP\n Auto Scaling Group Name\n -H HOOKNAME, --hookName HOOKNAME\n Life Cycle Hook Name\n -e EXECUTE, --execute EXECUTE\n The filepath of the triggered script\n -w WAIT, --wait WAIT Time between query loops in seconds (default: 60)\n```\n\nrds-instances.py\n----------------\n\nShows the main info regarding all the RDS instances such as: endpoint, engine, version, status etc.\n\n```\nusage: rds-instances.py [-h]\n\nList all the RDS instances\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/frommelmak/aws-scripts", "keywords": "aws amazon-web-services ec2-instance google-calendar-synchronization amazon", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "aws-scripts", "package_url": "https://pypi.org/project/aws-scripts/", "platform": "", "project_url": "https://pypi.org/project/aws-scripts/", "project_urls": { "Homepage": "http://github.com/frommelmak/aws-scripts" }, "release_url": "https://pypi.org/project/aws-scripts/0.0.13/", "requires_dist": [ "boto3 (>=1.6.3)", "argparse", "paramiko (>=1.15.2)", "google-api-python-client (>=1.7.3)", "oauth2client (>=4.1.2)", "boto (>=2.38.0)", "sshutil (>=0.9.7)", "botocore (>=1.9.3)" ], "requires_python": ">=2.7, <3", "summary": "Some useful AWS scripts I use from time to time", "version": "0.0.13" }, "last_serial": 4943320, "releases": { "0.0.11": [ { "comment_text": "", "digests": { "md5": "1b0954b12031e9adc30ccbf80949f8bc", "sha256": "63a49570a16600fb92154e981f6a089468e194d5270d3c1312f948a3ee5b6e9f" }, "downloads": -1, "filename": "aws_scripts-0.0.11-py2-none-any.whl", "has_sig": false, "md5_digest": "1b0954b12031e9adc30ccbf80949f8bc", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.7, <3", "size": 32393, "upload_time": "2018-08-13T11:22:49", "url": "https://files.pythonhosted.org/packages/fc/5c/3a2cb1003eff2e37d2067d70421a88578480350b96aa15576ff61be4d9f9/aws_scripts-0.0.11-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "32bc822a8660e252735e39acd2f0b590", "sha256": "d0ef097abb4b1a6df607a87d3a9796a57b26069af8da15e48b5b09835274f003" }, "downloads": -1, "filename": "aws-scripts-0.0.11.tar.gz", "has_sig": false, "md5_digest": "32bc822a8660e252735e39acd2f0b590", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <3", "size": 14281, "upload_time": "2018-08-13T11:22:51", "url": "https://files.pythonhosted.org/packages/1e/f9/898bc79b61c5af626523fd731bde97b9dfe40b2cd224486d2a03d634fbfc/aws-scripts-0.0.11.tar.gz" } ], "0.0.12": [ { "comment_text": "", "digests": { "md5": "4bf76adfb5c3a3927abae2d1c6bf6c7e", "sha256": "750a8e4a40649295abed6b51d9f77458d955eb2d161f543a3d7c6b05c9a8ed93" }, "downloads": -1, "filename": "aws-scripts-0.0.12.tar.gz", "has_sig": false, "md5_digest": "4bf76adfb5c3a3927abae2d1c6bf6c7e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <3", "size": 14327, "upload_time": "2019-01-11T16:53:15", "url": "https://files.pythonhosted.org/packages/df/2f/f13247609a33774b6fcd217aded42bb8043e65a24662f5c1059324689591/aws-scripts-0.0.12.tar.gz" } ], "0.0.13": [ { "comment_text": "", "digests": { "md5": "9d3b7124596ed3b9822edc98bdc6d8d5", "sha256": "7e0d12f2feb69bc5ad75fcd82c7f04b72e89edc2c084360cef3d3fd58f3c44eb" }, "downloads": -1, "filename": "aws_scripts-0.0.13-py2-none-any.whl", "has_sig": false, "md5_digest": "9d3b7124596ed3b9822edc98bdc6d8d5", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.7, <3", "size": 32664, "upload_time": "2019-03-15T09:22:23", "url": "https://files.pythonhosted.org/packages/8f/58/24860f38c710d4ae9724a088c8820edde83eefe92bc93b28263e3640f6c9/aws_scripts-0.0.13-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b1e9095b746daa3701fb3d8f6997c34", "sha256": "18ba511874216ad5cef9fdf2eb2ef2422151eb5192166f3b9d0b8aa4e0fad84d" }, "downloads": -1, "filename": "aws-scripts-0.0.13.tar.gz", "has_sig": false, "md5_digest": "7b1e9095b746daa3701fb3d8f6997c34", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <3", "size": 14435, "upload_time": "2019-03-15T09:22:25", "url": "https://files.pythonhosted.org/packages/fa/59/6fa06a2d02dff0963fab9838a90d69984db87e2ab07e2f0a45db557150f8/aws-scripts-0.0.13.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9d3b7124596ed3b9822edc98bdc6d8d5", "sha256": "7e0d12f2feb69bc5ad75fcd82c7f04b72e89edc2c084360cef3d3fd58f3c44eb" }, "downloads": -1, "filename": "aws_scripts-0.0.13-py2-none-any.whl", "has_sig": false, "md5_digest": "9d3b7124596ed3b9822edc98bdc6d8d5", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.7, <3", "size": 32664, "upload_time": "2019-03-15T09:22:23", "url": "https://files.pythonhosted.org/packages/8f/58/24860f38c710d4ae9724a088c8820edde83eefe92bc93b28263e3640f6c9/aws_scripts-0.0.13-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b1e9095b746daa3701fb3d8f6997c34", "sha256": "18ba511874216ad5cef9fdf2eb2ef2422151eb5192166f3b9d0b8aa4e0fad84d" }, "downloads": -1, "filename": "aws-scripts-0.0.13.tar.gz", "has_sig": false, "md5_digest": "7b1e9095b746daa3701fb3d8f6997c34", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <3", "size": 14435, "upload_time": "2019-03-15T09:22:25", "url": "https://files.pythonhosted.org/packages/fa/59/6fa06a2d02dff0963fab9838a90d69984db87e2ab07e2f0a45db557150f8/aws-scripts-0.0.13.tar.gz" } ] }