Welcome to a Better Boto!¶
Better Boto aims to reduce the burden of using AWS Boto3. AWS Boto3 is a low level SDK for interacting with AWS Services and sometimes it feels too low level or too crud like.
Better Boto is a collection of helper functions to make using AWS Boto easier. For example, it added a create_or_update method to the AWS CloudFormation client. It also provides some helpers for dealing with pagination operations and some help using AWS Organizations. Check out the API for more info.
Client¶
What is this?¶
With the following clients you can use them as context managers and they provide extra functionality for you. Each client is documented below:
Classes¶
-
class
betterboto.client.
ClientContextManager
(service_name, **kwargs)[source]¶ ClientContextManager allows you to use boto3 client as a python context manager. This allows you to perform the following:
with ClientContextManager('cloudformation') as cloudformation_client: cloudformation_client.create_stack(**args)
-
class
betterboto.client.
CrossAccountClientContextManager
(service_name, role_arn, role_session_name, **kwargs)[source]¶ CrossAccountClientContextManager allows you to use boto3 client as a python context manager for another account. This allows you to perform the following:
with CrossAccountClientContextManager( 'cloudformation', 'arn:aws:iam::0123456789010:role/deployer', 'deployment_account_session', ) as deployment_account_cloudformation: deployment_account_cloudformation.create_stack(**args)
-
class
betterboto.client.
CrossMultipleAccountsClientContextManager
(service_name, assumable_details, **kwargs)[source]¶ CrossMultipleAccountsClientContextManager allows you to use boto3 client as a python context manager for another account. This allows you to perform the following:
with CrossMultipleAccountsClientContextManager( 'cloudformation', [ ('arn:aws:iam::0123456789010:role/deployer', 'deployment_account_session'), ('arn:aws:iam::097167856333:role/deployer', 'deployment_account_session_nested'), ], ) as deployment_account_cloudformation: deployment_account_cloudformation.create_stack(**args)
-
class
betterboto.client.
MultiRegionClientContextManager
(service_name, regions, **kwargs)[source]¶ MultiRegionClientContextManager allows you to use boto3 client as a python context manager for multiple regions. This allows you to perform the following:
with MultiRegionClientContextManager('cloudformation', ['us-east-1','eu-west-1']) as cloudformation_clients: for region_name, cloudformation_client in cloudformation_clients.items(): cloudformation_client.create_stack(**args)
If you want to deploy to multiple regions at the same time then you should use Python Threads
CloudFormation helpers¶
What is this?¶
The following methods are added to clients instantiated using Betterboto:
Methods¶
-
betterboto.cloudformation.
create_or_update
(self, **kwargs)[source]¶ For the given template and stack name, this method will create a stack if it doesnt already exist otherwise it will generate a changeset and then execute it. This method will wait for the operation to complete before returning and in the instance of an error it will print out the stack events to help you debug more easily.
- Parameters
self – cloudformation client
kwargs – these are passed onto the create_stack and create_change_set method calls
- Returns
None
-
betterboto.cloudformation.
describe_stacks_single_page
(self, **kwargs)[source]¶ This will continue to call describe_stacks until there are no more pages left to retrieve. It will return the aggregated response in the same structure as describe_stacks does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the describe_stacks method call
- Returns
servicecatalog_client.describe_stacks.response
-
betterboto.cloudformation.
ensure_deleted
(self, StackName)[source]¶ This will check if there is a stack with the given StackName in a state that can be deleted. If there is, it will delete it.
- Parameters
self – cloudformation client
StackName – This is the name of the stack that should be deleted
- Returns
None
CodeBuild helpers¶
What is this?¶
The following methods are added to clients instantiated using Betterboto:
Methods¶
-
betterboto.codebuild.
start_build_and_wait_for_completion
(self, **kwargs)[source]¶ This will start a build of an AWS CodeBuild Project and wait for it to complete. It will return the result of the build.
- Parameters
self – codebuild client
kwargs – these are passed onto the start_build method call
- Returns
codebuild_client.batch_get_builds.response[0]
CodeCommit helpers¶
What is this?¶
The following methods are added to clients instantiated using Betterboto:
Methods¶
-
betterboto.codecommit.
list_branches_single_page
(self, **kwargs)[source]¶ This will continue to call list_branches until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_branches does.
- Parameters
self – codecommit client
kwargs – these are passed onto the list_branches method call
- Returns
codecommit_client.list_branches.response
GuardDuty helpers¶
What is this?¶
The following methods are added to clients instantiated using Betterboto:
Methods¶
-
betterboto.guardduty.
list_members_single_page
(self, **kwargs)[source]¶ This will continue to call list_members until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_members does.
- Parameters
self – guardduty client
kwargs – these are passed onto the list_members method call
- Returns
guardduty_client.list_members.response
Organizations helpers¶
What is this?¶
The following methods are added to clients instantiated using Betterboto:
Methods¶
-
betterboto.organizations.
convert_path_to_ou
(self, path)[source]¶ This method accepts a path and returns the ou. This raises an exception when converting / and you have more than one root
- Parameters
self – organizations client
path – organizations path
- Returns
the ou of the path specified
-
betterboto.organizations.
list_accounts_single_page
(self, **kwargs)[source]¶ This will continue to call list_accounts until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_accounts does.
- Parameters
self – organizations client
kwargs – these are passed onto the list_accounts method call
- Returns
organizations_client.list_accounts.response
-
betterboto.organizations.
list_children_nested
(self, **kwargs)[source]¶ This method will return a list of all children (either ACCOUNT or ORGANIZATIONAL_UNIT) for the given ParentId. It includes children, grandchildren lower levels of nesting.
- Parameters
self – organizations client
kwargs – these are passed onto the list_children method call
- Returns
list of children in the structure of [{‘Id’: “0123456789010”}, {‘Id’: “1009876543210”}]
-
betterboto.organizations.
list_children_single_page
(self, **kwargs)[source]¶ This will continue to call list_children until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_children does.
- Parameters
self – organizations client
kwargs – these are passed onto the list_children method call
- Returns
organizations_client.list_children.response
-
betterboto.organizations.
list_organizational_units_for_parent_single_page
(self, **kwargs)[source]¶ This will continue to call list_organizational_units_for_parent until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_organizational_units_for_parent does.
- Parameters
self – organizations client
kwargs – these are passed onto the list_organizational_units_for_parent method call
- Returns
organizations_client.list_organizational_units_for_parent.response
-
betterboto.organizations.
search_products_as_admin_single_page
(self, **kwargs)[source]¶ This will continue to call search_products_as_admin until there are no more pages left to retrieve. It will return the aggregated response in the same structure as search_products_as_admin does.
- Parameters
self – organizations client
kwargs – these are passed onto the search_products_as_admin method call
- Returns
organizations_client.search_products_as_admin.response
Service Catalog helpers¶
What is this?¶
The following methods are added to clients instantiated using Betterboto:
Methods¶
-
betterboto.servicecatalog.
list_launch_paths_single_page
(self, **kwargs)[source]¶ This will continue to call list_launch_paths until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_launch_paths does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the list_launch_paths method call
- Returns
servicecatalog_client.list_launch_paths.response
-
betterboto.servicecatalog.
list_portfolios_for_product_single_page
(self, **kwargs)[source]¶ This will continue to call list_portfolios_for_product until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_portfolios_for_product does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the list_portfolios_for_product method call
- Returns
servicecatalog_client.list_portfolios_for_product.response
-
betterboto.servicecatalog.
list_portfolios_single_page
(self, **kwargs)[source]¶ This will continue to call list_portfolios until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_portfolios does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the list_portfolios method call
- Returns
servicecatalog_client.list_portfolios.response
-
betterboto.servicecatalog.
list_provisioned_product_plans_single_page
(self, **kwargs)[source]¶ This will continue to call list_provisioned_product_plans until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_provisioned_product_plans does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the list_provisioned_product_plans method call
- Returns
servicecatalog_client.list_provisioned_product_plans.response
-
betterboto.servicecatalog.
list_provisioning_artifacts_single_page
(self, **kwargs)[source]¶ This will continue to call list_provisioning_artifacts until there are no more pages left to retrieve. It will return the aggregated response in the same structure as list_provisioning_artifacts does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the list_provisioning_artifacts method call
- Returns
servicecatalog_client.list_provisioning_artifacts.response
-
betterboto.servicecatalog.
search_products_as_admin_single_page
(self, **kwargs)[source]¶ This will continue to call search_products_as_admin until there are no more pages left to retrieve. It will return the aggregated response in the same structure as search_products_as_admin does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the search_products_as_admin method call
- Returns
servicecatalog_client.search_products_as_admin.response
-
betterboto.servicecatalog.
search_provisioned_products_single_page
(self, **kwargs)[source]¶ This will continue to call search_provisioned_products until there are no more pages left to retrieve. It will return the aggregated response in the same structure as search_provisioned_products does.
- Parameters
self – servicecatalog client
kwargs – these are passed onto the search_provisioned_products method call
- Returns
servicecatalog_client.search_provisioned_products.response