From 35612c90b05f5ea2fb6886176ae88fdf2c19633f Mon Sep 17 00:00:00 2001 From: Razique Mahroua Date: Mon, 24 Apr 2023 13:10:40 -0700 Subject: [PATCH] Fix #1774 --- plugins/modules/s3_lifecycle.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/modules/s3_lifecycle.py b/plugins/modules/s3_lifecycle.py index 9d5ea3b8ff6..62c2684644f 100644 --- a/plugins/modules/s3_lifecycle.py +++ b/plugins/modules/s3_lifecycle.py @@ -328,13 +328,13 @@ def build_rule(client, module): rule["Transitions"] = [] for transition in transitions: t_out = dict() - 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"] - if transition.get("storage_class"): - t_out["StorageClass"] = transition["storage_class"].upper() - rule["Transitions"].append(t_out) + if transition.get('transition_date'): + t_out['Date'] = transition['transition_date'] + elif transition.get('transition_days') is not None: + t_out['Days'] = int(transition['transition_days']) + if transition.get('storage_class'): + t_out['StorageClass'] = transition['storage_class'].upper() + rule['Transitions'].append(t_out) if noncurrent_version_transition_days is not None: rule["NoncurrentVersionTransitions"] = [ @@ -495,10 +495,11 @@ def create_lifecycle_rule(client, module): # Write lifecycle to bucket try: client.put_bucket_lifecycle_configuration( - 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 + 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 interpreted this as not changing anything changed = False except ( botocore.exceptions.ClientError,