{ "info": { "author": "Binh Le", "author_email": "lebinh.it@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "=================================\naq - Query AWS resources with SQL\n=================================\n\n``aq`` allows you to query your AWS resources (EC2 instances, S3 buckets, etc.) with plain SQL.\n\n.. image:: https://travis-ci.org/lebinh/aq.svg?branch=master\n :target: https://travis-ci.org/lebinh/aq\n\n.. image:: https://asciinema.org/a/79468.png\n :target: https://asciinema.org/a/79468\n\n*But why?*\n\nFun, mostly fun. But see sample queries below for useful queries that can be performed with ``aq``.\n\nUsage\n~~~~~\n::\n\n Usage:\n aq [options]\n aq [options] \n\n Options:\n --table-cache-ttl= number of seconds to cache the tables\n before we update them from AWS again [default: 300]\n -v, --verbose enable verbose logging\n\nRunning ``aq`` without specifying any query will start a REPL to run your queries interactively.\n\nSample queries\n~~~~~~~~~~~~~~\n\nOne of the most important benefit of being able to query which SQL is aggregation and join,\nwhich can be very complicated or even impossible to do with AWS CLI.\n\nTo count how many running instances per instance type\n-----------------------------------------------------\n::\n\n > SELECT instance_type, count(*) count\n FROM ec2_instances\n WHERE state->'Name' = 'running'\n GROUP BY instance_type\n ORDER BY count DESC\n +-----------------+---------+\n | instance_type | count |\n |-----------------+---------|\n | m4.2xlarge | 15 |\n | m4.xlarge | 6 |\n | r3.8xlarge | 6 |\n +-----------------+---------+\n\nFind instances with largest attached EBS volumes size\n-----------------------------------------------------\n::\n\n > SELECT i.id, i.tags->'Name' name, count(v.id) vols, sum(v.size) size, sum(v.iops) iops\n FROM ec2_instances i\n JOIN ec2_volumes v ON v.attachments -> 0 -> 'InstanceId' = i.id\n GROUP BY i.id\n ORDER BY size DESC\n LIMIT 3\n +------------+-----------+--------+--------+--------+\n | id | name | vols | size | iops |\n |------------+-----------+--------+--------+--------|\n | i-12345678 | foo | 4 | 2000 | 4500 |\n | i-12345679 | bar | 2 | 332 | 1000 |\n | i-12345687 | blah | 1 | 320 | 960 |\n +------------+-----------+--------+--------+--------+\n\nFind instances that allows access to port 22 in their security groups\n---------------------------------------------------------------------\n::\n\n > SELECT i.id, i.tags->'Name' name, sg.group_name\n FROM ec2_instances i\n JOIN ec2_security_groups sg ON instr(i.security_groups, sg.id)\n WHERE instr(sg.ip_permissions, '\"ToPort\": 22,')\n +------------+-----------+---------------------+\n | id | name | group_name |\n |------------+-----------+---------------------|\n | i-foobar78 | foobar | launch-wizard-1 |\n | i-foobar87 | blah | launch-wizard-2 |\n +------------+-----------+---------------------+\n\nAWS Credential\n~~~~~~~~~~~~~~\n\n``aq`` relies on ``boto3`` for AWS API access so all the\n`credential configuration mechanisms `_\nof boto3 will work. If you are using the AWS CLI then you can use ``aq`` without any further configurations.\n\nAvailable tables\n~~~~~~~~~~~~~~~~\n\nAWS resources are specified as table names in ``_`` format with:\n\n resource\n one of the `resources `_\n defined in boto3: ``ec2``, ``s3``, ``iam``, etc.\n collection\n one of the resource's `collections `_\n defined in boto3: ``instances``, ``images``, etc.\n\nAn optional schema (i.e. database) name can be used to specify the AWS region to query.\nIf you don't specify the schema name then boto's default region will be used.\n\n::\n\n -- to count the number of ec2 instances in AWS Singapore region\n SELECT count(*) FROM ap_southeast_1.ec2_instances\n\nNote that the region name is specified using underscore (``ap_southeast_1``) instead of dash (``ap-southeast-1``).\n\nAt the moment the full table list for AWS ``us_east_1`` region is\n\n.. list-table::\n\n * - cloudformation_stacks\n * - cloudwatch_alarms\n * - cloudwatch_metrics\n * - dynamodb_tables\n * - ec2_classic_addresses\n * - ec2_dhcp_options_sets\n * - ec2_images\n * - ec2_instances\n * - ec2_internet_gateways\n * - ec2_key_pairs\n * - ec2_network_acls\n * - ec2_network_interfaces\n * - ec2_placement_groups\n * - ec2_route_tables\n * - ec2_security_groups\n * - ec2_snapshots\n * - ec2_subnets\n * - ec2_volumes\n * - ec2_vpc_addresses\n * - ec2_vpc_peering_connections\n * - ec2_vpcs\n * - glacier_vaults\n * - iam_groups\n * - iam_instance_profiles\n * - iam_policies\n * - iam_roles\n * - iam_saml_providers\n * - iam_server_certificates\n * - iam_users\n * - iam_virtual_mfa_devices\n * - opsworks_stacks\n * - s3_buckets\n * - sns_platform_applications\n * - sns_subscriptions\n * - sns_topics\n * - sqs_queues\n\nQuery with structured value\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nQuite a number of resource contain structured value (e.g. instance tags) that cannot be use directly in SQL.\nWe keep and present these values as JSON serialized string and add a new operator ``->`` to make querying on them easier.\nThe ``->`` (replaced to ``json_get`` before execution) can be used to access an object field, ``object->'fieldName'``, or access\nan array item, ``array->index``::\n\n > SELECT '{\"foo\": \"bar\"}' -> 'foo'\n +-------------------------------------+\n | json_get('{\"foo\": \"bar\"}', 'foo') |\n |-------------------------------------|\n | bar |\n +-------------------------------------+\n > SELECT '[\"foo\", \"bar\", \"blah\"]' -> 1\n +--------------+\n | json_get(' |\n |--------------|\n | bar |\n +--------------+\n\nInstall\n~~~~~~~\n::\n\n pip install aq\n\nTests (with `nose`)\n~~~~~~~~~~~~~~~~~~~\n::\n\n nosetests", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lebinh/aq", "keywords": "aws sql query", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "aq", "package_url": "https://pypi.org/project/aq/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/aq/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/lebinh/aq" }, "release_url": "https://pypi.org/project/aq/0.1.1/", "requires_dist": [ "boto3", "docopt", "prompt-toolkit", "pygments", "pyparsing", "six", "tabulate" ], "requires_python": "", "summary": "Query AWS resources with SQL", "version": "0.1.1" }, "last_serial": 2219334, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "dedd6e2741de97f8e45d863ec9419cd0", "sha256": "af6753fa7392f2b5a71ad1f068e3fd183f23f60680940387474203262e728b51" }, "downloads": -1, "filename": "aq-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dedd6e2741de97f8e45d863ec9419cd0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16972, "upload_time": "2016-07-13T12:17:49", "url": "https://files.pythonhosted.org/packages/47/ee/5cc1ad2d830683c62e13e8b1d1b4b366653e9292dbcbe963315621f56ca7/aq-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e7402da0edf1b2d3fbe30b6974e064bb", "sha256": "cc6539f63c000210bd9e5b48f1aebf75f2ce1c1717da18740bc54ec039d24ba3" }, "downloads": -1, "filename": "aq-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e7402da0edf1b2d3fbe30b6974e064bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12423, "upload_time": "2016-07-13T12:17:53", "url": "https://files.pythonhosted.org/packages/14/68/9574786b5611f2cdb422f006ea9b96b9adff28eb2b64209dde266438a4ce/aq-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "e8eb14d8a0957de5deae4c458a6896d4", "sha256": "c4765080604c3a22f850ecf990b3585bd42e3fc03b23f1cac33ab5ca343ffcef" }, "downloads": -1, "filename": "aq-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e8eb14d8a0957de5deae4c458a6896d4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17191, "upload_time": "2016-07-13T12:59:40", "url": "https://files.pythonhosted.org/packages/16/33/2b436faffd09b45b3f274fc1464b8a7e22acf01b658f3b5a904f38bfab12/aq-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b8bb5b42993a6f2d9c7d42acefe30598", "sha256": "fed0c2f633007faee1653c23f144b86672c328c4d71c83509fab789c77591ebc" }, "downloads": -1, "filename": "aq-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b8bb5b42993a6f2d9c7d42acefe30598", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12611, "upload_time": "2016-07-13T12:59:43", "url": "https://files.pythonhosted.org/packages/0b/f6/2ad1a9e110c5f2860d55c920eda140bbdee5d7ed499d4e86233f1d39b758/aq-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e8eb14d8a0957de5deae4c458a6896d4", "sha256": "c4765080604c3a22f850ecf990b3585bd42e3fc03b23f1cac33ab5ca343ffcef" }, "downloads": -1, "filename": "aq-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e8eb14d8a0957de5deae4c458a6896d4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17191, "upload_time": "2016-07-13T12:59:40", "url": "https://files.pythonhosted.org/packages/16/33/2b436faffd09b45b3f274fc1464b8a7e22acf01b658f3b5a904f38bfab12/aq-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b8bb5b42993a6f2d9c7d42acefe30598", "sha256": "fed0c2f633007faee1653c23f144b86672c328c4d71c83509fab789c77591ebc" }, "downloads": -1, "filename": "aq-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b8bb5b42993a6f2d9c7d42acefe30598", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12611, "upload_time": "2016-07-13T12:59:43", "url": "https://files.pythonhosted.org/packages/0b/f6/2ad1a9e110c5f2860d55c920eda140bbdee5d7ed499d4e86233f1d39b758/aq-0.1.1.tar.gz" } ] }