Debian Codegraph @

ansible_collections/amazon/aws/plugins/module_utils/core.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright 2017 Michael De La Rue | Ansible
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 """This module adds shared support for generic Amazon AWS modules
7
8 In order to use this module, include it as part of a custom
9 module as shown below.
10
11 from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
12 module = AnsibleAWSModule(argument_spec=dictionary, supports_check_mode=boolean
13 mutually_exclusive=list1, required_together=list2)
14
15 The 'AnsibleAWSModule' module provides similar, but more restricted,
16 interfaces to the normal Ansible module. It also includes the
17 additional methods for connecting to AWS using the standard module arguments
18
19 m.resource('lambda') # - get an AWS connection as a boto3 resource.
20
21 or
22
23 m.client('sts') # - get an AWS connection as a boto3 client.
24
25 To make use of AWSRetry easier, it can now be wrapped around any call from a
26 module-created client. To add retries to a client, create a client:
27
28 m.client('ec2', retry_decorator=AWSRetry.jittered_backoff(retries=10))
29
30 Any calls from that client can be made to use the decorator passed at call-time
31 using the `aws_retry` argument. By default, no retries are used.
32
33 ec2 = m.client('ec2', retry_decorator=AWSRetry.jittered_backoff(retries=10))
34 ec2.describe_instances(InstanceIds=['i-123456789'], aws_retry=True)
35
36 The call will be retried the specified number of times, so the calling functions
37 don't need to be wrapped in the backoff decorator.
38 """
39
40 # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.arn
41 from .arn import parse_aws_arn # pylint: disable=unused-import
42
43 # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.botocore
44 from .botocore import HAS_BOTO3 # pylint: disable=unused-import
45 from .botocore import get_boto3_client_method_parameters # pylint: disable=unused-import
46 from .botocore import is_boto3_error_code # pylint: disable=unused-import
47 from .botocore import is_boto3_error_message # pylint: disable=unused-import
48 from .botocore import normalize_boto3_result # pylint: disable=unused-import
49
50 # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.exceptions
51 from .exceptions import AnsibleAWSError # pylint: disable=unused-import
52
53 # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.modules
54 from .modules import AnsibleAWSModule # pylint: disable=unused-import
55
56 # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.modules
57 from .transformation import scrub_none_parameters # pylint: disable=unused-import
58
59 # We will also export HAS_BOTO3 so end user modules can use it.
60 __all__ = ("AnsibleAWSModule", "HAS_BOTO3", "is_boto3_error_code", "is_boto3_error_message")