S3 lifecycle management via boto returns error 400 recently

0

We manage S3 lifecycles via Puppet and boto (NOT boto3) and it's worked for years. However in the past few months bucket.configure_lifecycle(lifecycle) is returning a 400 Bad Request error with the text 'At east one action needs to be specified in a rule'. As this code hasn't been modified at our end (either in Puppet or boto code installed or the OS version of the platform running the lifecycle rule or in Python2 version), is something in S3 changed to invalidate old boto request format? Even recreation of a lifecycle that used to be created now no longer runs correctly...

mattml
asked a year ago182 views
2 Answers
0

Is it possible for you to share the code you are using?

profile picture
EXPERT
answered a year ago
0

The following code is called (via Puppet) with a single parameter (the name of the host that is having it's lifecycle created) and stdout posted to a file

#!/usr/bin/python2 import sys from boto.s3.connection import S3Connection from boto.s3.lifecycle import Lifecycle, Expiration, Transition, Rule

name = sys.argv[1]

conn = S3Connection() bucket = conn.get_bucket('penmanconsulting-server-backups') lifecycle = bucket.get_lifecycle_config()

Eday = Expiration( days=7 ) Eweek = Expiration( days=28 ) Emonth = Expiration( days=365 ) Tmonth = Transition( days=1, storage_class='GLACIER' ) Tyear = Transition( days=1, storage_class='GLACIER' )

lifecycle.append( Rule( name+'-daily', '{host}/monthly/'.format( host=name ), 'Enabled', expiration=Eday )) lifecycle.append( Rule( name+'-weekly', '{host}/monthly/'.format( host=name ), 'Enabled', expiration=Eweek )) lifecycle.append( Rule( name+'-monthly', '{host}/monthly/'.format( host=name ), 'Enabled', expiration=Emonth, transition=Tmonth )) lifecycle.append( Rule( name+'-yearly', '{host}/yearly/'.format( host=name ), 'Enabled', transition=Tyear ))

not conditional, so that lifecycle rules can be updated.

bucket.configure_lifecycle(lifecycle) print "Lifecycle applied."

print "-----" print lifecycle.to_xml()

mattml
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions