-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge branch 'main' into patch-9
Showing
284 changed files
with
8,438 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
rules: | ||
indentation: | ||
ignore: &default_ignores | | ||
# automatically generated, we can't control it | ||
changelogs/changelog.yaml | ||
# Will be gone when we release and automatically reformatted | ||
changelogs/fragments/* | ||
document-start: | ||
ignore: *default_ignores | ||
line-length: | ||
ignore: *default_ignores | ||
max: 160 | ||
|
||
ignore-from-file: .gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
changelogs/fragments/1631-route53_health_check-added-calculcated.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
minor_changes: | ||
- route53_health_check - add support for another ``type`` choice called ``CALCULATED`` (https://github.com/ansible-collections/amazon.aws/pull/1631). | ||
- route53_health_check - add support for another ``type`` choice called ``CALCULATED`` (https://github.com/ansible-collections/amazon.aws/pull/1631). | ||
- route53_health_check - add support for a string list parameter called ``child_health_checks`` to specify health checks that must be healthy for the calculated health check (https://github.com/ansible-collections/amazon.aws/pull/1631). | ||
- route53_health_check - add support for an integer parameter called ``health_threshold`` to specify the minimum number of healthy child health checks that must be healthy for the calculated health check (https://github.com/ansible-collections/amazon.aws/pull/1631). | ||
- route53_health_check - add support for an integer parameter called ``health_threshold`` to specify the minimum number of healthy child health checks that must be healthy for the calculated health check (https://github.com/ansible-collections/amazon.aws/pull/1631). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
minor_changes: | ||
- rds_cluster - add support for another ``state`` choice called ``started``. This starts the rds cluster (https://github.com/ansible-collections/amazon.aws/pull/1647/files). | ||
- rds_cluster - add support for another ``state`` choice called ``stopped``. This stops the rds cluster (https://github.com/ansible-collections/amazon.aws/pull/1647/files). | ||
- rds_cluster - add support for another ``state`` choice called ``stopped``. This stops the rds cluster (https://github.com/ansible-collections/amazon.aws/pull/1647/files). |
2 changes: 0 additions & 2 deletions
2
changelogs/fragments/1681-cloudformation-add-support-for-disable_rollback-to-update.yml
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
changelogs/fragments/1685-ssm_parameter-update-examples-to-use-fqcn.yml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
changelogs/fragments/1705-rds_cluster-add-support-remove-cluster-from-global-db.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
minor_changes: | ||
- rds_cluster - Add support for removing cluster from global db (https://github.com/ansible-collections/amazon.aws/pull/1705). |
4 changes: 4 additions & 0 deletions
4
changelogs/fragments/1767-elb_application_lb_info-Throttling.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bugfixes: | ||
- elb_application_lb_info - ensure all API queries use the retry decorator (https://github.com/ansible-collections/amazon.aws/issues/1767). | ||
minor_changes: | ||
- elb_application_lb_info - drop redundant ``describe_load_balancers`` call fetching ``ip_address_type`` (https://github.com/ansible-collections/amazon.aws/pull/1768). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- amazon.aws collection - apply isort code formatting to ensure consistent formatting of code (https://github.com/ansible-collections/amazon.aws/pull/1771). |
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/1778-elb_application_lb_info-fetch-subsets.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- "elb_application_lb_info - add new parameters ``include_attributes``, ``include_listeners`` and ``include_listener_rules`` to optionally speed up module by fetching less information (https://github.com/ansible-collections/amazon.aws/pull/1778)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
trivial: | ||
- galaxy.yml - add description to collection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
trivial: | ||
- Update integration tests to reflect renamed plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
trivial: | ||
- ec2_ami - fix version_added for org owners. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
breaking_changes: | ||
- The amazon.aws collection has dropped support for ``botocore<1.29.0`` and | ||
``boto3<1.26.0``. Most modules will continue to work with older versions of the AWS SDK, however | ||
compatability with older versions of the SDK is not guaranteed and will not be tested. When using | ||
older versions of the SDK a warning will be emitted by Ansible | ||
(https://github.com/ansible-collections/amazon.aws/pull/1763). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
major_changes: | ||
- aws_region_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be | ||
updated to use ``amazon.aws.aws_region_info``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
major_changes: | ||
- iam_access_key - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_access_key``. | ||
- iam_access_key_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_access_key_info``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
major_changes: | ||
- iam_group - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_group`` (https://github.com/ansible-collections/amazon.aws/pull/1755). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
major_changes: | ||
- iam_managed_policy - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_managed_policy`` (https://github.com/ansible-collections/amazon.aws/pull/1762). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
major_changes: | ||
- iam_mfa_device_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_mfa_device_info`` (https://github.com/ansible-collections/amazon.aws/pull/1761). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
major_changes: | ||
- iam_password_policy - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_password_policy``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
major_changes: | ||
- iam_role - The module has been migrated from the ``community.aws`` collection. Playbooks | ||
using the Fully Qualified Collection Name for this module should be updated to use | ||
``amazon.aws.iam_role`` (https://github.com/ansible-collections/amazon.aws/pull/1760). | ||
- iam_role_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.iam_role_info`` (https://github.com/ansible-collections/amazon.aws/pull/1760). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
major_changes: | ||
- aws_s3_bucket_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be | ||
updated to use ``amazon.aws.aws_s3_bucket_info``. | ||
- s3_bucket_info - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be | ||
updated to use ``amazon.aws.s3_bucket_info``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
major_changes: | ||
- sts_assume_role - The module has been migrated from the ``community.aws`` collection. | ||
Playbooks using the Fully Qualified Collection Name for this module should be updated | ||
to use ``amazon.aws.sts_assume_role``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
breaking_changes: | ||
- amazon.aws collection - due to the AWS SDKs announcing the end of support | ||
for Python less than 3.7 (https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/) | ||
support for Python less than 3.7 by this collection wss been deprecated in release 6.0.0 and removed in release 7.0.0. | ||
(https://github.com/ansible-collections/amazon.aws/pull/1763). | ||
|
||
# We've already announced the deprecation for <3.8 (with 6.0.0), dropping support for <3.9 on ours side will happen | ||
# after April 2026. This is about 2 years + 5 months away assuming a November 7.0.0 release, we could announce | ||
# the deprecation now, but assuming we release 8.0.0 in about 6 months a just short of 2 year | ||
# deprecation feels fine given it's predictable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2017 Ansible Project | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
DOCUMENTATION = r""" | ||
module: aws_region_info | ||
short_description: Gather information about AWS regions | ||
version_added: 1.0.0 | ||
version_added_collection: community.aws | ||
description: | ||
- Gather information about AWS regions. | ||
author: | ||
- 'Henrique Rodrigues (@Sodki)' | ||
options: | ||
filters: | ||
description: | ||
- A dict of filters to apply. | ||
- Each dict item consists of a filter key and a filter value. | ||
- See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRegions.html) for possible filters. | ||
- Filter names and values are case sensitive. | ||
- You can use underscores instead of dashes (-) in the filter keys. | ||
- Filter keys with underscores will take precedence in case of conflict. | ||
default: {} | ||
type: dict | ||
extends_documentation_fragment: | ||
- amazon.aws.common.modules | ||
- amazon.aws.region.modules | ||
- amazon.aws.boto3 | ||
""" | ||
|
||
EXAMPLES = r""" | ||
# Note: These examples do not set authentication details, see the AWS Guide for details. | ||
# Gather information about all regions | ||
- amazon.aws.aws_region_info: | ||
# Gather information about a single region | ||
- amazon.aws.aws_region_info: | ||
filters: | ||
region-name: eu-west-1 | ||
""" | ||
|
||
RETURN = r""" | ||
regions: | ||
returned: on success | ||
description: > | ||
Regions that match the provided filters. Each element consists of a dict with all the information related | ||
to that region. | ||
type: list | ||
sample: "[{ | ||
'endpoint': 'ec2.us-west-1.amazonaws.com', | ||
'region_name': 'us-west-1' | ||
}]" | ||
""" | ||
|
||
try: | ||
from botocore.exceptions import BotoCoreError | ||
from botocore.exceptions import ClientError | ||
except ImportError: | ||
pass # Handled by AnsibleAWSModule | ||
|
||
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict | ||
|
||
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule | ||
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry | ||
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list | ||
|
||
|
||
def main(): | ||
argument_spec = dict( | ||
filters=dict(default={}, type="dict"), | ||
) | ||
|
||
module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) | ||
|
||
connection = module.client("ec2", retry_decorator=AWSRetry.jittered_backoff()) | ||
|
||
# Replace filter key underscores with dashes, for compatibility | ||
sanitized_filters = dict(module.params.get("filters")) | ||
for k in module.params.get("filters").keys(): | ||
if "_" in k: | ||
sanitized_filters[k.replace("_", "-")] = sanitized_filters[k] | ||
del sanitized_filters[k] | ||
|
||
try: | ||
regions = connection.describe_regions( | ||
aws_retry=True, Filters=ansible_dict_to_boto3_filter_list(sanitized_filters) | ||
) | ||
except (BotoCoreError, ClientError) as e: | ||
module.fail_json_aws(e, msg="Unable to describe regions.") | ||
|
||
module.exit_json(regions=[camel_dict_to_snake_dict(r) for r in regions["Regions"]]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,314 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2021 Ansible Project | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
DOCUMENTATION = r""" | ||
--- | ||
module: iam_access_key | ||
version_added: 2.1.0 | ||
version_added_collection: community.aws | ||
short_description: Manage AWS IAM User access keys | ||
description: | ||
- Manage AWS IAM user access keys. | ||
author: | ||
- Mark Chappell (@tremble) | ||
options: | ||
user_name: | ||
description: | ||
- The name of the IAM User to which the key belongs. | ||
required: true | ||
type: str | ||
aliases: ['username'] | ||
id: | ||
description: | ||
- The ID of the access key. | ||
- Required when I(state=absent). | ||
- Mutually exclusive with I(rotate_keys). | ||
required: false | ||
type: str | ||
state: | ||
description: | ||
- Create or remove the access key. | ||
- When I(state=present) and I(id) is not defined a new key will be created. | ||
required: false | ||
type: str | ||
default: 'present' | ||
choices: [ 'present', 'absent' ] | ||
active: | ||
description: | ||
- Whether the key should be enabled or disabled. | ||
- Defaults to C(true) when creating a new key. | ||
required: false | ||
type: bool | ||
aliases: ['enabled'] | ||
rotate_keys: | ||
description: | ||
- When there are already 2 access keys attached to the IAM user the oldest | ||
key will be removed and a new key created. | ||
- Ignored if I(state=absent) | ||
- Mutually exclusive with I(id). | ||
required: false | ||
type: bool | ||
default: false | ||
notes: | ||
- For security reasons, this module should be used with B(no_log=true) and (register) functionalities | ||
when creating new access key. | ||
extends_documentation_fragment: | ||
- amazon.aws.common.modules | ||
- amazon.aws.region.modules | ||
- amazon.aws.boto3 | ||
""" | ||
|
||
EXAMPLES = r""" | ||
# Note: These examples do not set authentication details, see the AWS Guide for details. | ||
|
||
- name: Create a new access key | ||
amazon.aws.iam_access_key: | ||
user_name: example_user | ||
state: present | ||
no_log: true | ||
|
||
- name: Delete the access_key | ||
amazon.aws.iam_access_key: | ||
user_name: example_user | ||
id: AKIA1EXAMPLE1EXAMPLE | ||
state: absent | ||
""" | ||
|
||
RETURN = r""" | ||
access_key: | ||
description: A dictionary containing all the access key information. | ||
returned: When the key exists. | ||
type: complex | ||
contains: | ||
access_key_id: | ||
description: The ID for the access key. | ||
returned: success | ||
type: str | ||
sample: AKIA1EXAMPLE1EXAMPLE | ||
create_date: | ||
description: The date and time, in ISO 8601 date-time format, when the access key was created. | ||
returned: success | ||
type: str | ||
sample: "2021-10-09T13:25:42+00:00" | ||
user_name: | ||
description: The name of the IAM user to which the key is attached. | ||
returned: success | ||
type: str | ||
sample: example_user | ||
status: | ||
description: | ||
- The status of the key. | ||
- C(Active) means it can be used. | ||
- C(Inactive) means it can not be used. | ||
returned: success | ||
type: str | ||
sample: Inactive | ||
secret_access_key: | ||
description: | ||
- The secret access key. | ||
- A secret access key is the equivalent of a password which can not be changed and as such should be considered sensitive data. | ||
- Secret access keys can only be accessed at creation time. | ||
returned: When a new key is created. | ||
type: str | ||
sample: example/Example+EXAMPLE+example/Example | ||
deleted_access_key_id: | ||
description: | ||
- The access key deleted during rotation. | ||
returned: When a key was deleted during the rotation of access keys | ||
type: str | ||
sample: AKIA1EXAMPLE1EXAMPLE | ||
""" | ||
|
||
try: | ||
import botocore | ||
except ImportError: | ||
pass # caught by AnsibleAWSModule | ||
|
||
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict | ||
|
||
from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code | ||
from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result | ||
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule | ||
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry | ||
from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters | ||
|
||
|
||
def delete_access_key(access_keys, user, access_key_id): | ||
if not access_key_id: | ||
return False | ||
|
||
if access_key_id not in access_keys: | ||
return False | ||
|
||
if module.check_mode: | ||
return True | ||
|
||
try: | ||
client.delete_access_key( | ||
aws_retry=True, | ||
UserName=user, | ||
AccessKeyId=access_key_id, | ||
) | ||
except is_boto3_error_code("NoSuchEntityException"): | ||
# Generally occurs when race conditions have happened and someone | ||
# deleted the key while we were checking to see if it existed. | ||
return False | ||
except ( | ||
botocore.exceptions.ClientError, | ||
botocore.exceptions.BotoCoreError, | ||
) as e: # pylint: disable=duplicate-except | ||
module.fail_json_aws(e, msg=f'Failed to delete access key "{access_key_id}" for user "{user}"') | ||
|
||
return True | ||
|
||
|
||
def update_access_key(access_keys, user, access_key_id, enabled): | ||
if access_key_id not in access_keys: | ||
module.fail_json( | ||
msg=f'Access key "{access_key_id}" not found attached to User "{user}"', | ||
) | ||
|
||
changes = dict() | ||
access_key = access_keys.get(access_key_id) | ||
|
||
if enabled is not None: | ||
desired_status = "Active" if enabled else "Inactive" | ||
if access_key.get("status") != desired_status: | ||
changes["Status"] = desired_status | ||
|
||
if not changes: | ||
return False | ||
|
||
if module.check_mode: | ||
return True | ||
|
||
try: | ||
client.update_access_key(aws_retry=True, UserName=user, AccessKeyId=access_key_id, **changes) | ||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: | ||
module.fail_json_aws( | ||
e, | ||
changes=changes, | ||
msg=f'Failed to update access key "{access_key_id}" for user "{user}"', | ||
) | ||
return True | ||
|
||
|
||
def create_access_key(access_keys, user, rotate_keys, enabled): | ||
changed = False | ||
oldest_key = False | ||
|
||
if len(access_keys) > 1 and rotate_keys: | ||
sorted_keys = sorted(list(access_keys), key=lambda k: access_keys[k].get("create_date", None)) | ||
oldest_key = sorted_keys[0] | ||
changed |= delete_access_key(access_keys, user, oldest_key) | ||
|
||
if module.check_mode: | ||
if changed: | ||
return dict(deleted_access_key=oldest_key) | ||
return True | ||
|
||
try: | ||
results = client.create_access_key(aws_retry=True, UserName=user) | ||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: | ||
module.fail_json_aws(e, msg=f'Failed to create access key for user "{user}"') | ||
results = camel_dict_to_snake_dict(results) | ||
access_key = results.get("access_key") | ||
access_key = normalize_boto3_result(access_key) | ||
|
||
# Update settings which can't be managed on creation | ||
if enabled is False: | ||
access_key_id = access_key["access_key_id"] | ||
access_keys = {access_key_id: access_key} | ||
update_access_key(access_keys, user, access_key_id, enabled) | ||
access_key["status"] = "Inactive" | ||
|
||
if oldest_key: | ||
access_key["deleted_access_key"] = oldest_key | ||
|
||
return access_key | ||
|
||
|
||
def get_access_keys(user): | ||
try: | ||
results = client.list_access_keys(aws_retry=True, UserName=user) | ||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: | ||
module.fail_json_aws(e, msg=f'Failed to get access keys for user "{user}"') | ||
if not results: | ||
return None | ||
|
||
results = camel_dict_to_snake_dict(results) | ||
access_keys = results.get("access_key_metadata", []) | ||
if not access_keys: | ||
return [] | ||
|
||
access_keys = normalize_boto3_result(access_keys) | ||
access_keys = {k["access_key_id"]: k for k in access_keys} | ||
return access_keys | ||
|
||
|
||
def main(): | ||
global module | ||
global client | ||
|
||
argument_spec = dict( | ||
user_name=dict(required=True, type="str", aliases=["username"]), | ||
id=dict(required=False, type="str"), | ||
state=dict(required=False, choices=["present", "absent"], default="present"), | ||
active=dict(required=False, type="bool", aliases=["enabled"]), | ||
rotate_keys=dict(required=False, type="bool", default=False), | ||
) | ||
|
||
required_if = [ | ||
["state", "absent", ("id",)], | ||
] | ||
mutually_exclusive = [ | ||
["rotate_keys", "id"], | ||
] | ||
|
||
module = AnsibleAWSModule( | ||
argument_spec=argument_spec, | ||
supports_check_mode=True, | ||
) | ||
|
||
client = module.client("iam", retry_decorator=AWSRetry.jittered_backoff()) | ||
|
||
changed = False | ||
state = module.params.get("state") | ||
user = module.params.get("user_name") | ||
access_key_id = module.params.get("id") | ||
rotate_keys = module.params.get("rotate_keys") | ||
enabled = module.params.get("active") | ||
|
||
access_keys = get_access_keys(user) | ||
results = dict() | ||
|
||
if state == "absent": | ||
changed |= delete_access_key(access_keys, user, access_key_id) | ||
else: | ||
# If we have an ID then we should try to update it | ||
if access_key_id: | ||
changed |= update_access_key(access_keys, user, access_key_id, enabled) | ||
access_keys = get_access_keys(user) | ||
results["access_key"] = access_keys.get(access_key_id, None) | ||
# Otherwise we try to create a new one | ||
else: | ||
secret_key = create_access_key(access_keys, user, rotate_keys, enabled) | ||
if isinstance(secret_key, bool): | ||
changed |= secret_key | ||
else: | ||
changed = True | ||
results["access_key_id"] = secret_key.get("access_key_id", None) | ||
results["secret_access_key"] = secret_key.pop("secret_access_key", None) | ||
results["deleted_access_key_id"] = secret_key.pop("deleted_access_key", None) | ||
if secret_key: | ||
results["access_key"] = secret_key | ||
results = scrub_none_parameters(results) | ||
|
||
module.exit_json(changed=changed, **results) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2021 Ansible Project | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
DOCUMENTATION = r""" | ||
--- | ||
module: iam_access_key_info | ||
version_added: 2.1.0 | ||
version_added_collection: community.aws | ||
short_description: fetch information about AWS IAM User access keys | ||
description: | ||
- 'Fetches information AWS IAM user access keys.' | ||
- 'Note: It is not possible to fetch the secret access key.' | ||
author: | ||
- Mark Chappell (@tremble) | ||
options: | ||
user_name: | ||
description: | ||
- The name of the IAM User to which the keys belong. | ||
required: true | ||
type: str | ||
aliases: ['username'] | ||
|
||
extends_documentation_fragment: | ||
- amazon.aws.common.modules | ||
- amazon.aws.region.modules | ||
- amazon.aws.boto3 | ||
""" | ||
|
||
EXAMPLES = r""" | ||
# Note: These examples do not set authentication details, see the AWS Guide for details. | ||
|
||
- name: Fetch Access keys for a user | ||
amazon.aws.iam_access_key_info: | ||
user_name: example_user | ||
""" | ||
|
||
RETURN = r""" | ||
access_key: | ||
description: A dictionary containing all the access key information. | ||
returned: When the key exists. | ||
type: list | ||
elements: dict | ||
contains: | ||
access_key_id: | ||
description: The ID for the access key. | ||
returned: success | ||
type: str | ||
sample: AKIA1EXAMPLE1EXAMPLE | ||
create_date: | ||
description: The date and time, in ISO 8601 date-time format, when the access key was created. | ||
returned: success | ||
type: str | ||
sample: "2021-10-09T13:25:42+00:00" | ||
user_name: | ||
description: The name of the IAM user to which the key is attached. | ||
returned: success | ||
type: str | ||
sample: example_user | ||
status: | ||
description: | ||
- The status of the key. | ||
- C(Active) means it can be used. | ||
- C(Inactive) means it can not be used. | ||
returned: success | ||
type: str | ||
sample: Inactive | ||
""" | ||
|
||
try: | ||
import botocore | ||
except ImportError: | ||
pass # caught by AnsibleAWSModule | ||
|
||
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict | ||
|
||
from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result | ||
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule | ||
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry | ||
|
||
|
||
def get_access_keys(user): | ||
try: | ||
results = client.list_access_keys(aws_retry=True, UserName=user) | ||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: | ||
module.fail_json_aws(e, msg=f'Failed to get access keys for user "{user}"') | ||
if not results: | ||
return None | ||
|
||
results = camel_dict_to_snake_dict(results) | ||
access_keys = results.get("access_key_metadata", []) | ||
if not access_keys: | ||
return [] | ||
|
||
access_keys = normalize_boto3_result(access_keys) | ||
access_keys = sorted(access_keys, key=lambda d: d.get("create_date", None)) | ||
return access_keys | ||
|
||
|
||
def main(): | ||
global module | ||
global client | ||
|
||
argument_spec = dict( | ||
user_name=dict(required=True, type="str", aliases=["username"]), | ||
) | ||
|
||
module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) | ||
|
||
client = module.client("iam", retry_decorator=AWSRetry.jittered_backoff()) | ||
|
||
changed = False | ||
user = module.params.get("user_name") | ||
access_keys = get_access_keys(user) | ||
|
||
module.exit_json(changed=changed, access_keys=access_keys) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.