允许一个区域中的 cloudformation 访问不同区域中的 lambda 支持的自定义资源

allowing cloudformation in one region to access a lambda backed custom resource in a different region

我在 us-east-2 中有一个 lambda 支持的自定义资源。当我 运行 us-east-2 中的 cloudformation 模板时,它工作得很好。当我转到 us-east-1 并尝试使用相同的 cloudformation 模板时,出现错误:

Function not found: arn:aws:lambda:us-east-1:account-id:function:func_name (Service: AWSLambda; Status Code: 404; Error Code: ResourceNotFoundException;

两个 VPC 之间存在 VPC 对等,但这似乎没有任何区别。当我尝试在不同地区的同一个账户中部署相同的功能时,我得到一个错误,我需要找到一个解决方案。

我认为一个区域中的 CloudFormation 模板不可能引用另一个区域中的 Lambda 自定义资源。

您需要在希望将其用作自定义资源的任何区域复制该函数。

我认为您无法做到这一点,但唯一的方法是在多个区域复制完全相同的资源(通过 cfn)。我认为最好的选择是使用 cloud-formation 以通用方式配置所有资源,这样您就可以在需要时简单地将其部署到多个区域。

我所说的通用的意思是,不要硬编码任何与 aws 环境相关的细节或系统级变量,而是在您尝试创建堆栈时通过 cli 命令将这些变量的值传递到模板中。

看起来现在可以使用新的 AWS 堆栈集。

A stack set lets you create stacks in AWS accounts across regions by using a single AWS CloudFormation template. All the resources included in each stack are defined by the stack set's AWS CloudFormation template

参考: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html