ars_def#
See ARSBase.
- aws_resource_search.ars_def.validate_bsm(bsm: BotoSesManager)[source]#
validate the boto session manager. It has to have
sts.get_caller_identity()permission because we need to get aws_account_id, and be able to getaws_region.
- class aws_resource_search.ars_def.ARS(bsm: BotoSesManager, aws_console: aws_console_url.AWSConsole, searcher_finder: SearcherFinder = <factory>, dir_index: ~pathlib.Path = PosixPath('/home/docs/.aws_resource_search/.index'), dir_cache: ~pathlib.Path = PosixPath('/home/docs/.aws_resource_search/.cache'), cache: ~diskcache.core.Cache = None)[source]#
This class stands for “AWS Resource Search Base”, provides method to search AWS resources in Python.
In order to enable auto-complete in IDE, we need to explicitly declare per-resource-type searcher method in this class. However, we don’t want to maintain this wiring logics. Instead, we use Jinja template to generate, a code
Usage:
# import the singleton ARS object >>> from aws_resource_search.api import ars >>> ars.s3_bucket.search("my bucket") [ { "id": "my-bucket", "name": "my-bucket", ... }, { ... }, ]
This class is a singleton object that holds all context data such as
boto_session_manager.BotoSesManager,aws_console_url.api.AwsConsole.- classmethod from_profile(profile: Optional[str] = Sentinel('NOTHING'))[source]#
Create a new
ARSBaseobject by an AWS profile. If None, then use the default AWS profile.
- get_searcher(resource_type: str) T_SEARCHER[source]#
Get corresponding
aws_resource_search.res_lib.Searcherobject by resource type.
- set_profile(profile: Optional[str] = Sentinel('NOTHING'))[source]#
Set all boto session related attributes (
bsm,aws_console,search_patterns) to use a new AWS profile.Logics:
Update the singleton
bsmobject by reset its cache and use a new AWS profile.Update the
aws_consoleobject to use the newbsm- Since we updated the
bsm, we also need to reset thesearcher_finder cache to recreate all
Searcherobjects.
- Since we updated the