Skip to content

Commit

Permalink
cloudfront_distribution: now honours the enabled setting (#1824) (#1837)
Browse files Browse the repository at this point in the history
[manual backport stable-5] cloudfront_distribution: now honours the enabled setting (#1824)

cloudfront_distribution: now honours the enabled setting
SUMMARY
Fixes: #1823
The enabled: false setting was ignored, because here we were falling back to the default True not only when the setting was None, but also when it was False. ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
cloudfront_distribution
Reviewed-by: Markus Bergholz [email protected]
Reviewed-by: Alina Buzachis
(cherry picked from commit 5594769)
SUMMARY


ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <[email protected]>
  • Loading branch information
alinabuzachis committed Jun 1, 2023
1 parent 48edfac commit 4d55e01
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- cloudfront_distribution - now honours the ``enabled`` setting (https://github.com/ansible-collections/community.aws/issues/1823).
4 changes: 2 additions & 2 deletions plugins/modules/cloudfront_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2009,8 +2009,8 @@ def validate_common_distribution_parameters(self, config, enabled, aliases, logg
if alias not in aliases])
config['aliases'] = ansible_list_to_cloudfront_list(aliases)
if logging is not None:
config['logging'] = self.validate_logging(logging)
config['enabled'] = enabled or config.get('enabled', self.__default_distribution_enabled)
config["logging"] = self.validate_logging(logging)
config["enabled"] = enabled if enabled is not None else config.get("enabled", self.__default_distribution_enabled)
if price_class is not None:
self.validate_attribute_with_allowed_values(price_class, 'price_class', self.__valid_price_classes)
config['price_class'] = price_class
Expand Down
15 changes: 14 additions & 1 deletion tests/integration/targets/cloudfront_distribution/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
- set_fact:
distribution_id: '{{ cf_distribution.id }}'

- name: ensure that default value of 'enabled' is 'true'
assert:
that:
- cf_distribution.changed
- cf_distribution.enabled

- name: ensure that default value of 'ipv6_enabled' is 'false'
assert:
that:
Expand Down Expand Up @@ -282,8 +288,9 @@
wait: yes
state: absent

- name: create distribution with tags
- name: create cloudfront distribution with tags and as disabled
cloudfront_distribution:
enabled: false
origins:
- domain_name: "{{ resource_prefix }}2.example.com"
id: "{{ resource_prefix }}2.example.com"
Expand All @@ -296,6 +303,12 @@
- set_fact:
distribution_id: '{{ cf_second_distribution.id }}'

- name: ensure that the value of 'enabled' is 'false'
assert:
that:
- cf_second_distribution.changed
- not cf_second_distribution.enabled

- name: ensure tags were set on creation
assert:
that:
Expand Down

0 comments on commit 4d55e01

Please sign in to comment.