Skip to content

Commit

Permalink
s3_lifecycle - fix invalid value type for transitions list (ansible-c…
Browse files Browse the repository at this point in the history
…ollections#1788)

s3_lifecycle - fix invalid value type for transitions list

Depends-On: ansible-collections#1792
SUMMARY
Fixes ansible-collections#1774
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
s3_lifecycle
ADDITIONAL INFORMATION
Forces casting to integer for the transition_days parameter of a transitions list.

Reviewed-by: Mark Chappell
  • Loading branch information
rmahroua authored May 5, 2023
1 parent f43f5b8 commit acb9daf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/20230424-s3_lifecycle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- s3_lifecycle - fix invalid value type for transitions list (https://github.com/ansible-collections/community.aws/issues/1774)
4 changes: 2 additions & 2 deletions plugins/modules/s3_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def build_rule(client, module):
if transition.get("transition_date"):
t_out["Date"] = transition["transition_date"]
elif transition.get("transition_days") is not None:
t_out["Days"] = transition["transition_days"]
t_out["Days"] = int(transition["transition_days"])
if transition.get("storage_class"):
t_out["StorageClass"] = transition["storage_class"].upper()
rule["Transitions"].append(t_out)
Expand Down Expand Up @@ -498,7 +498,7 @@ def create_lifecycle_rule(client, module):
aws_retry=True, Bucket=name, LifecycleConfiguration=lifecycle_configuration
)
except is_boto3_error_message("At least one action needs to be specified in a rule"):
# Amazon interpretted this as not changing anything
# Amazon interpreted this as not changing anything
changed = False
except (
botocore.exceptions.ClientError,
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/s3_lifecycle/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
security_token: '{{ security_token | default(omit) }}'
region: '{{ aws_region }}'
s3_lifecycle:
wait: yes
wait: true
block:

# ============================================================
Expand All @@ -33,7 +33,7 @@
prefix: "{{ item }}"
status: enabled
state: present
wait: yes
wait: true
register: output
loop:
- rule_1
Expand All @@ -51,7 +51,7 @@
prefix: "{{ item }}"
status: enabled
state: absent
wait: yes
wait: true
register: output
loop:
- rule_1
Expand Down Expand Up @@ -700,6 +700,6 @@
s3_bucket:
name: "{{item}}"
state: absent
ignore_errors: yes
ignore_errors: true
with_items:
- '{{ bucket_name }}'

0 comments on commit acb9daf

Please sign in to comment.