简体   繁体   English

如何将“手动创建”的资源添加到 cloudformation 模板

[英]how to add "manually created" resources to the cloudformation template

I initially created all my resources in AWS manually.我最初在 AWS 中手动创建了我的所有资源。 Now I'm trying to use CloudFormation (SAM) templates to create all my new resources.现在我正在尝试使用 CloudFormation (SAM) 模板来创建我所有的新资源。 Is there any way I can all my old (manually created) resource to this CF template and hence forth use this CF to make modification to those old resources?有什么办法可以将我所有旧的(手动创建的)资源都放到这个 CF 模板中,然后使用这个 CF 来修改那些旧资源吗?

Not possible to add existing resources to a cloudformation template and have them managed from there on in with Cloudformation - but you can have a look at using CloudFormer ( https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-cloudformer.html ) to create a cloudformation template for you from existing resources.无法将现有资源添加到 cloudformation 模板并使用 Cloudformation 从那里管理它们 - 但您可以查看使用 CloudFormer( https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn -using-cloudformer.html ) 从现有资源中为您创建一个 cloudformation 模板。

It won't manage the existing resources, but it will create a template so that you can launch the same resources again.它不会管理现有资源,但会创建一个模板,以便您可以再次启动相同的资源。

This is now possible with an update from AWS, see here for more details这现在可以通过 AWS 的更新实现,请参阅此处了解更多详细信息

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html

This is unfortunately not possible.不幸的是,这是不可能的。

To manage resources with CloudFormation, they have to be created first by CloudFormation.要使用 CloudFormation 管理资源,必须先由 CloudFormation 创建它们。

You will need to find some sort of "migration path" from your existing resources to the ones created by CloudFormation.您将需要找到从现有资源到 CloudFormation 创建的资源的某种“迁移路径”。

It is not possible to add existing resources to CloudFormation template directly, but you can deploy a CloudFormer stack to create a template from existing resources.无法将现有资源直接添加到 CloudFormation 模板,但您可以部署 CloudFormer 堆栈以从现有资源创建模板。

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-cloudformer.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-cloudformer.html

After successful creation of that template, you can use the cross-stack reference in which you can define parameters to import/export values of existing resources.成功创建该模板后,您可以使用跨堆栈引用,您可以在其中定义参数以导入/导出现有资源的值。

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html

Also, for more details of how to define parameters and import/export values, you can go through the below link: https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-reference-resource/此外,有关如何定义参数和导入/导出值的更多详细信息,您可以访问以下链接: https ://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-reference-resource/

Note: After deployment of the template created by CloudFormer, you can vanish your existing resources as it newly deployed through the stack.注意:部署由 CloudFormer 创建的模板后,您可以消失现有资源,因为它是通过堆栈新部署的。

Hope this helps!希望这可以帮助!

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

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