aws package¶
Subpackages¶
- aws.autoscaling package
- aws.cloudtrail package
- aws.ec2 package
- Submodules
- aws.ec2.helpers module
- aws.ec2.resources module
- aws.ec2.test_ec2_all_eips_bound module
- aws.ec2.test_ec2_ebs_snapshot_not_too_old module
- aws.ec2.test_ec2_ebs_snapshots_are_private module
- aws.ec2.test_ec2_ebs_volume_attached_to_instance module
- aws.ec2.test_ec2_ebs_volume_encrypted module
- aws.ec2.test_ec2_ebs_volume_not_piops module
- aws.ec2.test_ec2_instance_has_required_tags module
- aws.ec2.test_ec2_instance_on_acceptable_ami module
- aws.ec2.test_ec2_security_group_in_use module
- aws.ec2.test_ec2_security_group_opens_all_ports module
- aws.ec2.test_ec2_security_group_opens_all_ports_to_all module
- aws.ec2.test_ec2_security_group_opens_all_ports_to_self module
- aws.ec2.test_ec2_security_group_opens_specific_ports_to_all module
- aws.ec2.test_ec2_vpc_flow_log_enabled module
- Module contents
- aws.elasticache package
- aws.elasticsearch package
- aws.iam package
- Submodules
- aws.iam.helpers module
- aws.iam.resources module
- aws.iam.test_iam_access_key_is_old module
- aws.iam.test_iam_admin_user_with_access_keys module
- aws.iam.test_iam_admin_user_without_mfa module
- aws.iam.test_iam_cross_account_admin_roles_require_mfa module
- aws.iam.test_iam_user_is_inactive module
- aws.iam.test_iam_user_without_mfa module
- Module contents
- aws.rds package
- Submodules
- aws.rds.helpers module
- aws.rds.resources module
- aws.rds.test_rds_db_instance_backup_enabled module
- aws.rds.test_rds_db_instance_encrypted module
- aws.rds.test_rds_db_instance_is_multiaz module
- aws.rds.test_rds_db_instance_is_postgres_with_invalid_certificate module
- aws.rds.test_rds_db_instance_minor_version_updates_enabled module
- aws.rds.test_rds_db_instance_not_publicly_accessible_by_vpc_sg module
- aws.rds.test_rds_db_instance_storage_type_not_piops module
- aws.rds.test_rds_db_security_group_does_not_grant_public_access module
- aws.rds.test_rds_db_snapshot_encrypted module
- aws.rds.test_rds_db_snapshot_not_publicly_accessible module
- aws.rds.test_rds_db_snapshot_not_too_old module
- Module contents
- aws.redshift package
- aws.route53 package
- aws.s3 package
- Submodules
- aws.s3.helpers module
- aws.s3.resources module
- aws.s3.test_s3_bucket_cors_disabled module
- aws.s3.test_s3_bucket_does_not_grant_all_principals_all_actions module
- aws.s3.test_s3_bucket_has_life_cycle_policy module
- aws.s3.test_s3_bucket_logging_enabled module
- aws.s3.test_s3_bucket_no_world_acl module
- aws.s3.test_s3_bucket_versioning_enabled module
- aws.s3.test_s3_bucket_versioning_mfa_delete_enabled module
- aws.s3.test_s3_bucket_web_hosting_disabled module
- Module contents
- aws.sns package
Submodules¶
aws.client module¶
-
aws.client.
get_session
(profile: Optional[str] = None) → botocore.session.Session[source]¶ Returns a new or cached botocore session for the AWS profile.
-
aws.client.
get_client
(profile: str, region: str, service: str) → botocore.client.BaseClient[source]¶ Returns a new or cached botocore service client for the AWS profile, region, and service.
Warns when a service is not available for a region, which means we need to update botocore or skip that call for that region.
-
aws.client.
full_results
(client: botocore.client.BaseClient, method: str, args: List[str], kwargs: Dict[str, Any]) → Dict[str, Any][source]¶ Returns JSON results for an AWS botocore call. Flattens paginated results (if any).
-
class
aws.client.
AWSAPICall
(profile, region, service, method, args, kwargs)[source]¶ Bases:
tuple
-
profile
: Optional[str]¶ Alias for field number 0
-
region
: Optional[str]¶ Alias for field number 1
-
service
: Optional[str]¶ Alias for field number 2
-
method
: Optional[str]¶ Alias for field number 3
-
args
: List[str]¶ Alias for field number 4
-
kwargs
: Dict[str, Any]¶ Alias for field number 5
-
-
aws.client.
cache_key
(call: aws.client.AWSAPICall) → str[source]¶ Returns the fullname (directory and filename) for an AWS API call.
>>> cache_key(default_call._replace( ... profile='profile', ... region='region', ... service='service_name', ... method='method_name', ... args=['arg1', 'arg2'], ... kwargs=dict(kwarg1=True))) 'pytest_aws/profile/region/service_name/method_name/9965c005f623cd9130dd5a6dbdee87de.json'
-
aws.client.
get_aws_resource
(service_name: str, method_name: str, call_args: List[str], call_kwargs: Dict[str, Any], cache: Optional[_pytest.cacheprovider.Cache], profiles: List[Optional[str]], regions: List[str], result_from_error: Optional[Callable[[Any, Any], Any]] = None, debug_calls: bool = False, debug_cache: bool = False) → Generator[Dict[str, Any], None, None][source]¶ Fetches and yields AWS API JSON responses for all profiles and regions (list params)
-
class
aws.client.
BotocoreClient
(profiles: List[Optional[str]], regions: Optional[List[str]], cache: _pytest.cacheprovider.Cache, debug_calls: bool, debug_cache: bool, offline: bool)[source]¶ Bases:
object
-
get
(service_name: str, method_name: str, call_args: List[str], call_kwargs: Dict[str, Any], profiles: Optional[List[Optional[str]]] = None, regions: Optional[List[str]] = None, result_from_error: Optional[Callable[[Any, Any], Any]] = None, do_not_cache: bool = False) → aws.client.BotocoreClient[source]¶
-
values
() → Iterable[Any][source]¶ Returns the wrapped value
>>> c = BotocoreClient([None], None, None, None, None, offline=True) >>> c.results = [] >>> c.values() []
-
extract_key
(key: str, default: Any = None) → aws.client.BotocoreClient[source]¶ From an iterable of dicts returns the value with the given keys discarding other values:
>>> c = BotocoreClient([None], None, None, None, None, offline=True) >>> c.results = [{'id': 1}, {'id': 2}] >>> c.extract_key('id').results [1, 2]
When the key does not exist it returns the second arg which defaults to None:
>>> c = BotocoreClient([None], None, None, None, None, offline=True) >>> c.results = [{'id': 1}, {}] >>> c.extract_key('id').results [1, None]
Propagates the ‘__pytest_meta’ key to dicts and lists of dicts:
>>> c = BotocoreClient([None], None, None, None, None, offline=True) >>> c.results = [{'Attrs': {'Name': 'Test'}, '__pytest_meta': {'meta': 'dict'}}] >>> c.extract_key('Attrs').results [{'Name': 'Test', '__pytest_meta': {'meta': 'dict'}}] >>> c.results = [{'Tags': [{'Name': 'Test', 'Value': 'Tag'}], '__pytest_meta': {'meta': 'dict'}}] >>> c.extract_key('Tags').results [[{'Name': 'Test', 'Value': 'Tag', '__pytest_meta': {'meta': 'dict'}}]]
But not to primitives:
>>> c.results = [{'PolicyNames': ['P1', 'P2']}] >>> c.extract_key('PolicyNames').results [['P1', 'P2']]
Errors when the outer dict is missing a meta key:
>>> c = BotocoreClient([None], None, None, None, None, offline=True) >>> c.results = [{'Attrs': {'Name': 'Test'}}] >>> c.extract_key('Attrs') Traceback (most recent call last): ... KeyError: '__pytest_meta'
-
flatten
() → aws.client.BotocoreClient[source]¶ Flattens one level of a nested list:
>>> c = BotocoreClient([None], None, None, None, None, offline=True) >>> c.results = [['A', 1], ['B']] >>> c.flatten().values() ['A', 1, 'B']
Only works for a list of lists:
>>> c.results = [{'A': 1}, {'B': 2}] >>> c.flatten().values() Traceback (most recent call last): ... TypeError: can only concatenate list (not "dict") to list
-
debug
() → aws.client.BotocoreClient[source]¶
-