A simple SQLAlchemy wrapper around Steampipe.
Currently this is a work in progress. Models exist for the AWS plugin, others will be added in the future.
- Free software: BSD license
- Documentation: [WIP] https://steampipe-alchemy.readthedocs.io.
Install, setup, and start steampipe with the aws plugin.
# We're assuming the the AWS credentials are set in the environment here.
from steampipe_alchemy import SteamPipe
steam = SteamPipe()
steam.install(['aws']) # Downloads and installs steampipe with the aws plugin.
steam.update_config(aws={ # Modifies ~/.local/share/steampipe_alchemy/config/aws.spc
"plugin": "aws",
"regions": ['us-east-1', 'us-west-1', 'us-west-2']
})
steam.start() # Steampipe will be stopped when the script exits or when stop() is called.
We can then use the SQLAlchemy models to query AWS.
from steampipe_alchemy.models import AwsVpc
for i in steam.query(AwsVpc).limit(2):
print(i.vpc_id + ':')
print(' CIDR: ' + i.cidr_block)
print(' Region: ' + i.region)
Which will produce something like:
vpc-c65487a0
CIDR: 172.31.0.0/16
Region: us-west-1
vpc-0a2a5413bab086b36
CIDR: 172.31.0.0/16
Region: us-east-2
The models also have to_json and to_dict mixins:
first_vpc = steam.query(AwsVpc).first().to_dict()
print(first_vpc['cidr_block'])
The function SteamPipe.query is a small wrapper around sqlalchemy.orm.Query. It is setup to use the steampipe sqlalchemy session and has type annotations which enable IDE completion on both the Model results and the Query class.
Models are located in steampipe_alchemy.models
and are automatically generated with ./scripts/generate_models.py
.
- MacOS or Linux.
- Python3.7 or newer.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.