mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make aws_ses_identity module work when region is provided via environment or config. (#51627)
fixes #51531
This commit is contained in:
parent
46f8bd47ce
commit
30aeab4709
3 changed files with 33 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- aws_ses_identity module works when region is provided using config or environment variables rather than the region parameter (https://github.com/ansible/ansible/issues/51531)
|
|
@ -215,7 +215,7 @@ notification_attributes:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.aws.core import AnsibleAWSModule
|
from ansible.module_utils.aws.core import AnsibleAWSModule
|
||||||
from ansible.module_utils.ec2 import camel_dict_to_snake_dict, AWSRetry
|
from ansible.module_utils.ec2 import camel_dict_to_snake_dict, AWSRetry, get_aws_connection_info
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ def main():
|
||||||
state = module.params.get("state")
|
state = module.params.get("state")
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
region = module.params.get('region')
|
region = get_aws_connection_info(module, boto3=True)[0]
|
||||||
account_id = get_account_id(module)
|
account_id = get_account_id(module)
|
||||||
validate_params_for_identity_present(module)
|
validate_params_for_identity_present(module)
|
||||||
create_or_update_identity(connection, module, region, account_id)
|
create_or_update_identity(connection, module, region, account_id)
|
||||||
|
|
|
@ -111,6 +111,35 @@
|
||||||
state: absent
|
state: absent
|
||||||
<<: *aws_connection_info
|
<<: *aws_connection_info
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
# Test for https://github.com/ansible/ansible/issues/51531
|
||||||
|
# because aws region is explicitly used rather than just to
|
||||||
|
# obtain a connection, make sure this still works when
|
||||||
|
# region comes from an environment rather than a parameter.
|
||||||
|
- name: test register identity without explicit region
|
||||||
|
block:
|
||||||
|
- name: register email identity without explicit region
|
||||||
|
aws_ses_identity:
|
||||||
|
identity: "{{ email_identity }}"
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
region: "{{ omit }}"
|
||||||
|
register: result
|
||||||
|
environment:
|
||||||
|
AWS_DEFAULT_REGION: "{{ aws_region }}"
|
||||||
|
- name: assert changed is True
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result.changed == True
|
||||||
|
- import_tasks: assert_defaults.yaml
|
||||||
|
vars:
|
||||||
|
identity: "{{ email_identity }}"
|
||||||
|
always:
|
||||||
|
- name: cleanup email identity
|
||||||
|
aws_ses_identity:
|
||||||
|
identity: "{{ email_identity }}"
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
# ============================================================
|
||||||
- name: test register email identity check mode
|
- name: test register email identity check mode
|
||||||
block:
|
block:
|
||||||
- name: register email identity check mode
|
- name: register email identity check mode
|
||||||
|
|
Loading…
Add table
Reference in a new issue