简体   繁体   English

想要从不同的 VPC 云格式模板访问 VPC 值

[英]Want to access VPC value from different VPC cloud-formation template

I've created different cloudformation template of VPC at different account.我在不同的帐户中创建了 VPC 的不同 cloudformation 模板。 I want to access VPC value (Nacl, security Group, natGateway, vpcPeering) from different VPC to my current VPC cloudformation template(output not work for me)我想从不同的 VPC 访问 VPC 值(Nacl、安全组、natGateway、vpcPeering)到我当前的 VPC cloudformation 模板(输出对我不起作用)

I don't think this is possible.我不认为这是可能的。 Normally, one CloudFormation template can refer to another by name or using import/export.通常,一个 CloudFormation 模板可以通过名称或使用导入/导出来引用另一个。

However, this would not work if accessing a stack in another account or another region.但是,如果访问另一个帐户或另一个区域中的堆栈,这将不起作用

You will need to pass this information into the template via the Parameters.您需要通过参数将此信息传递到模板中。

An alternative is to create a Custom Resource , which is an AWS Lambda function.另一种方法是创建一个 Custom Resource ,它是一个 AWS Lambda 函数。 With the right permissions, the Custom Resource in Account-A could retrieve information from a CloudFormation stack in Account-B, then return the values to the stack.有了正确的权限,账户-A 中的自定义资源可以从账户-B 中的 CloudFormation 堆栈中检索信息,然后将值返回到堆栈。 These values could then be referenced in other parts of the template.然后可以在模板的其他部分引用这些值。

The Lambda function would need to assume an IAM Role in Account-B, where that Role has permission to query CloudFormation to obtain the values. Lambda 函数需要在 Account-B 中承担一个 IAM 角色,该角色有权查询 CloudFormation 以获取值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM