以下是aws s3api put-bucket-notification-configuration --bucket bucket-name --notification-configuration file://s3_lambda.json
# s3_lambda.json
{
"LambdaFunctionConfigurations": [
{
"LambdaFunctionArn": {"Fn::ImportValue": "RekogModerationLambdaFunction"},
"Events": [
"s3:ObjectCreated:*"
],
"Filter": {
"Key": {
"FilterRules": [
{
"Name": "prefix",
"Value": "upload/"
}
]
}
}
}
]
}
aws> cloudformation list-exports
{
"Exports": [
{
"ExportingStackId": "arn:aws:cloudformation:ap-northeast-2:300378067049:stack/spooncast-lambda-rekog-sam-sm-test/d8452dd0-8678-11e8-9ab8-50fae7d43856",
"Name": "RekogModerationLambdaFunction",
"Value": "arn:aws:lambda:ap-northeast-2:300378067049:function:spooncast-lambda-rekog-sam-sm-test-moderation"
}
]
}
看看我在json中使用Fn::ImportValue
的原因。
实际上,我希望CloudFomration
函数起作用,并将适当的值放在LambdaFunctionArn
中。
但是,看起来没有,返回错误。 (如果我将Arn
字符串直接不起作用,则可以正常工作)
Parameter validation failed:
Invalid type for parameter NotificationConfiguration.LambdaFunctionConfigurations[0].LambdaFunctionArn, value: OrderedDict([('Fn::ImportValue', 'RekogModerationLambdaFunction')]), type: <class 'collections.OrderedDict'>, valid types: <class 'str'>
AWS api不支持CloudFormation
函数是正确的。
可以,但是我用错了吗?