Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3_lifecycle: support value '0' for transition_days #1077

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- s3_lifecycle - add support of value *0* for ``transition_days`` (https://github.com/ansible-collections/community.aws/pull/1077).
4 changes: 2 additions & 2 deletions plugins/modules/s3_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def build_rule(client, module):
t_out = dict()
if transition.get('transition_date'):
t_out['Date'] = transition['transition_date']
elif transition.get('transition_days'):
elif transition.get('transition_days') is not None:
t_out['Days'] = transition['transition_days']
if transition.get('storage_class'):
t_out['StorageClass'] = transition['storage_class'].upper()
Expand Down Expand Up @@ -596,7 +596,7 @@ def main():
'noncurrent_version_transition_days',
'noncurrent_version_transitions')
for param in required_when_present:
if module.params.get(param):
if module.params.get(param) is None:
break
else:
msg = "one of the following is required when 'state' is 'present': %s" % ', '.join(required_when_present)
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/targets/s3_lifecycle/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,30 @@
prefix: /something
register: output

- assert:
that:
- output is not changed
# ============================================================
- name: Create a lifecycle policy, with glacier and transition_days to 0
s3_lifecycle:
name: '{{ bucket_name }}'
transition_days: 0
storage_class: glacier
prefix: /something
register: output

- assert:
that:
- output is changed
# ============================================================
- name: Create a lifecycle policy, with glacier and transition_days to 0 (idempotency)
s3_lifecycle:
name: '{{ bucket_name }}'
transition_days: 0
storage_class: glacier
prefix: /something
register: output

- assert:
that:
- output is not changed
Expand Down