Make aws_ses_identity module work when region is provided via environment or config. (#51627)

fixes #51531
pull/55396/merge
Ed Costello 6 years ago committed by Sloane Hertel
parent 46f8bd47ce
commit 30aeab4709

@ -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…
Cancel
Save