简体   繁体   English

云层如何运作

[英]How Cloud Formation Works

I see that there are a lot of success stories using CloudFormation, we're planning to use it to make sure our Prod/Dev environments are identical. 我看到有很多使用CloudFormation的成功案例,我们计划使用它来确保我们的Prod / Dev环境相同。 I heard that its aa great place to have a single file, in version control, for deploying multiple similar environments. 我听说在版本控制中拥有一个用于部署多个类似环境的文件的好地方。 I've a doubt, lets say if I use CloudFormer and create a template of say my DB instance and save it GIT, and say in next 10-15 days I make couple of changes like add new volumes in instance to store DataFiles, or delete some volumes etc, Now, when I use that Template in say our Dev Environment will it reflect the volumes which I added/deleted. 我有一个疑问,可以说,如果我使用CloudFormer并创建一个说我的数据库实例的模板并将其保存为GIT,然后说在接下来的10-15天内进行了几处更改,例如在实例中添加新卷以存储DataFiles,或者删除一些卷等,现在,当我在说我们的开发环境中使用该模板时,它将反映我添加/删除的卷。 I mean how does it work behind the scene. 我的意思是它在幕后如何运作。

This is the basic way to use CloudFormation: 这是使用CloudFormation的基本方法:

  1. Create a JSON template describing your stack. 创建一个描述您的堆栈的JSON模板。 You can write it manually, or write code that creates the JSON for you. 您可以手动编写它,也可以编写为您创建JSON的代码。

  2. Create one or more stacks based on the template. 根据模板创建一个或多个堆栈。

  3. Whenever you want to change something, edit your template (always committing changes to version control) and update the stack(s). 每当您要更改某些内容时,请编辑模板(始终将更改提交到版本控制)并更新堆栈。

You will often have several templates, where stacks based on one template uses resources created by stacks based on other templates. 您通常会有几个模板,其中基于一个模板的堆栈使用由基于其他模板的堆栈创建的资源。 Outputs and parameters are good for coordinating this. 输出和参数很好地协调了这一点。

Most importantly: You should never change resources created using CloudFormation in any other way than by changing the stack template and updating the stack. 最重要的是:除更改堆栈模板和更新堆栈外,切勿以其他任何方式更改使用CloudFormation创建的资源。

No, such changes would not be reflected automatically. 不,此类更改不会自动反映。

A CloudFormation template is a declarative description of AWS resources. CloudFormation模板是对AWS资源的声明性描述。 When you create a Stack from a template, AWS will provision all resources described in the template. 当您从模板创建堆栈时,AWS将置备模板中描述的所有资源。 You can also update a stack with new resources or delete entire stacks. 您还可以使用新资源更新堆栈或删除整个堆栈。

ClodFormer is a separate tool that will scan you account for resources and create a template describing them. ClodFormer是一个单独的工具,它将扫描您帐户中的资源并创建描述它们的模板。

So, if you create two stacks from the same template, they will be similar only after created, but totally separate lives thereafter. 因此,如果您从同一模板创建两个堆栈,则仅在创建后它们将是相似的,但此后将完全分开。 But you can have resources that are shared between stacks, for example, you can have one database stack that is referenced by two application stacks, if that makes sense to your environment. 但是您可以拥有在堆栈之间共享的资源,例如,如果对您的环境有意义,则可以有一个由两个应用程序堆栈引用的数据库堆栈。

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

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