0

方法签名:我尝试以一些不同的方式更改实现,但没有帮助。

import troposphere.s3 as S3
class LifecycleConfiguration(AWSProperty):
props = {
    'Rules': ([LifecycleRule], True),
}

class LifecycleRule(AWSProperty):
props = {
    'ExpirationDate': (basestring, False),
    'ExpirationInDays': (positive_integer, False),
    'Id': (basestring, False),
    'Prefix': (basestring, False),
    'Status': (basestring, True),
    'Transition': (LifecycleRuleTransition, False),
}

测试实施

myLifecycleConfiguration = S3.LifecycleConfiguration(title='myLifecycleConfiguration',
                                                 Rules=S3.LifecycleRule(title="check"))

错误签名

TypeError: Rules is <class 'troposphere.s3.LifecycleRule'>, expected [<class 'troposphere.s3.LifecycleRule'>]
4

1 回答 1

1

这很正常,错误消息告诉您问题出在哪里: LifecycleConfiguration 的“Rules”属性应该是 LifecycleRule 对象的列表(参见代码:“Rules”:([LifecycleRule],True), )

但是,当您创建 S3.LifecycleConfiguration 时,您使用单个 LifecycleRule 对象来提供“Rules”属性。

你应该写:

    myLifecycleConfiguration = S3.LifecycleConfiguration(
      title='myLifecycleConfiguration',Rules=[S3.LifecycleRule(title="check")])
于 2014-12-28T22:43:07.830 回答