我有一个通过 CloudFormation 模板作为自定义资源调用的 lambda 函数。它创建/删除 AWS Connect 实例。API 调用工作正常,但我似乎无法终止自定义资源调用,因此最后一个 CF 块仍然是 CREATE_IN_PROGRESS。无论我从异步函数返回什么,它都不会成功终止 CF 执行。
我能够像在https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/walkthrough-custom-resources-lambda-lookup-amiids.html 中那样成功地使用非异步处理程序,但我需要多个 API 调用并等待完成,因此需要异步处理程序。
下面是最简单形式的代码,尽管我已经尝试了几乎所有的方法,包括使用回调和上下文(即exports.handler = async function(event, context, callback) {...}),这两者都应该是不需要异步处理程序。我试过使用 cfn-response 直接发送一个似乎被异步处理程序忽略的响应。我试过直接返回带有和不带有等待的承诺,尝试返回包含各种 responseStatus 和 responseData 的变量,但似乎没有任何效果。
Transform: 'AWS::Serverless-2016-10-31'
Parameters:
IdentityManagementType:
Description: The type of identity management for your Amazon Connect users.
Type: String
AllowedValues: ["SAML", "CONNECT_MANAGED", "EXISTING_DIRECTORY"]
Default: "SAML"
InboundCallsEnabled:
Description: Whether your contact center handles incoming contacts.
Type: String
AllowedValues: [true, false]
Default: true
InstanceAlias:
Description: The name for your instance.
Type: …Run Code Online (Sandbox Code Playgroud)