我正在尝试为多个部门创建 AWS SSM 混合激活。我的 IDE 告诉我 datetime 不可调用,我收到的错误消息是:
Traceback (most recent call last):
File "C:\Users\username\bin\Create-Activation.py", line 23, in <module>
ExpirationDate = datetime(y, m, d),
TypeError: 'module' object is not callable
变量 y、m 和 d 被传递给 ExpirationDate 对象。我使用 Amazon 和 Boto3 文档作为指南。
有人可以帮我理解 ExpirationDate 对象失败的原因吗?
import boto3
import datetime
client = boto3.client('ssm')
current_date = datetime.date.today()
creation_date = current_date.strftime('%Y%m%d')
end_date = current_date + datetime.timedelta(days=30)
y = end_date.year
m = end_date.month
d = end_date.day
divisions = ['div1', 'div2', 'div3']
#def lambda_handler(event, context):
for x in divisions:
client.create_activation(
Description = (x + '-' + 'creation_date'),
#DefaultInstanceName = 'string',
IamRole = 'MySSMServiceRole',
RegistrationLimit = 200,
ExpirationDate = datetime(y, m, d),
Tags=[
{
'Key': 'Division',
'Value': x
},
]
)
print('\n ' + x + '-creation_date was create.')