-
Notifications
You must be signed in to change notification settings - Fork 398
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 encounters error KeyError: 'Rules' when there are no lifecycle configuration rules on bucket #2077
Comments
I updated the pip package of boto and boto3 since I saw a warning relating to the fact that my versions weren't supported when applying after defining a manual rule but I get the same error message :(
|
From what I can understand the problem seems to be here and the cause is that we do not check if the key Rules exist and since there is no lifecycle rules then we get nothing back (no json) Here is the output I get when fetching the lifecycle configuration rules when there is none:
I think adding an if else to check if the key Rules exists would resolve this edge case:
|
Same issue here (mostly the same use case. I confirmed that if I set a dummy lifecycle rule on the bucket, I can change it after. So the problem is exactly as described, when the bucket has no lifecycle rule set. |
Summary
Hi :) ,
When I try to use the community.aws.s3_lifecycle module from either community.aws collection 7.2.0 or 7.2.1 to create a lifecycle configuration rule on a s3 bucket created by openshift data foundation using noobaa on OpenShift 4.15.5 with OpenShift Data Foundation operator version v4.14.5-rhodf. The error happens when the bucket has no lifecycle configuration rule and the line where the error happens in the module is here . It seems like the module isn't handling the case where there is no lifecycle configuration rule.
If I use the awscli to create a lifecycle configuration rule then run my ansible playbook then there is no error and the module functions correctly and creates the rule specified. If I then remove all rules and run the playbook again then I can reproduce the issue
I didn't find something similar in an other issue but maybe I missed one.
Let me know if you need more information and I will do my best
Thanks for your great work,
Jeremy
Issue Type
Bug Report
Component Name
s3_lifecycle
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
RHEL 9.3
Steps to Reproduce
Expected Results
I expected the s3_lifecycle module to create the lifecycle configuration rule data_expire_withoutprefix
Actual Results
The s3_lifecyle encounters a module error
Code of Conduct
The text was updated successfully, but these errors were encountered: