Skip to content

Commit

Permalink
s3_lifecycle: support value '0' for transition_days
Browse files Browse the repository at this point in the history
  • Loading branch information
fmenabe committed Apr 19, 2022
1 parent 3f434f3 commit fdf2296
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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).
2 changes: 1 addition & 1 deletion 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
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 onezone_ia and transition_days to 0
s3_lifecycle:
name: '{{ bucket_name }}'
transition_days: 0
storage_class: onezone_ia
prefix: /something
register: output

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

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

0 comments on commit fdf2296

Please sign in to comment.