简体   繁体   English

用于多个参数文件和单个模板的 CloudFormation

[英]CloudFormation for multiple parameter files and a single template

I am currently storing all my parameters in Systems Manager Parameter Store and referencing them in CloudFormation stack.我目前将所有参数存储在 Systems Manager Parameter Store 中,并在 CloudFormation 堆栈中引用它们。

I am now stuck in a scenario where the parameters vary for the same Cloudformation template.我现在陷入了同一个 Cloudformation 模板的参数不同的场景。

For instance server A, has parameters m5.large instance type, su.net 1, host name 1 and likewise server B can have m5.xlarge, su.net 2, host name 2 and so on.例如服务器 A,具有参数 m5.large 实例类型、su.net 1、主机名 1,同样服务器 B 可以具有 m5.xlarge、su.net 2、主机名 2 等。 These 2 parameters are for the same CFN template.这 2 个参数用于相同的 CFN 模板。

How can I handle this situation in a CI/CD manner?我如何以 CI/CD 方式处理这种情况?

My current setup involves SSM Parameter store -> CloudWatch Events -> CodePipeline -> Cloudformation.我当前的设置涉及 SSM Parameter store -> CloudWatch Events -> CodePipeline -> Cloudformation。

I am Assuming you use AWS CodePipeline.我假设您使用 AWS CodePipeline。 Each CodePipeline stage consists of multiple stage actions .每个 CodePipeline 阶段由多个阶段操作组成。 On of the action configuration properties is the CloudFormation template, but also the The action can be configured to include the CloudFormation template, but also a template configuration can be provided.动作配置属性之一是 CloudFormation 模板,也可以配置动作以包含 CloudFormation 模板,还可以提供模板配置 If you define the server name as a parameter in the CloudFormation stack then you can provide a different configuration for each CloudFormation parameter.如果您将服务器名称定义为 CloudFormation 堆栈中的参数,则可以为每个 CloudFormation 参数提供不同的配置。

Assuming you define only one server in the CloudFormation stack and use the template twice in your codepipeline, then you can provide a different configuration to both stage actions.假设您只在 CloudFormation 堆栈中定义一个服务器并在代码管道中使用该模板两次,那么您可以为两个阶段操作提供不同的配置。 Based on this configuration you can decide which parameter in the parameter store you want to retrieve.基于此配置,您可以决定要检索参数存储中的哪个参数。 Of course this implies that your parameter store should be parameterized as well eg instead of parameter instancetype you might have parameter servera/instancetype and serverb/instancetype当然,这意味着您的参数存储也应该被参数化,例如,您可能有参数 servera/ servera/instancetypeserverb/instancetype而不是参数instancetype

However I think it is best if you just define the parameter in the Template Configuration file provided to the action declaration.但是,我认为最好只在提供给操作声明的模板配置文件中定义参数。 So for example define the parameter instancetype in your CloudFormation template and use two different configuration files ( one for each stack) where the first Template Configuration file might say instancetype: m5.large and the second configuration file instancetype: m5.xlarge .因此,例如在您的 CloudFormation 模板中定义参数instancetype并使用两个不同的配置文件(每个堆栈一个),其中第一个模板配置文件可能instancetype: m5.large和第二个配置文件instancetype: m5.xlarge This makes your CloudFormation stack history more explicit, easier to read, and makes the use of the parameter store for non-secrets no longer necessary.这使您的 CloudFormation 堆栈历史更加明确、更易于阅读,并且不再需要为非机密使用参数存储。

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

相关问题 CloudFormation 参数模板错误:参数不是字母数字 - CloudFormation Parameter Template Error : Parameter is non alphanumeric 用于创建多个 SQS 的 Cloudformation 模板 - Cloudformation template to create multiple SQS CloudFormation模板-通过参数选择设置容器镜像 - CloudFormation Template - Setting Container Image by Parameter Selection 如何在 CloudFormation 模板中将多个 URL 传递给 AllowOrigins - How to Pass Multiple URLs to AllowOrigins in CloudFormation Template 从 CloudFormation 模板中的 DropDownList 选择多个值 - Selecting multiple values from DropDownList in CloudFormation Template 在 CloudFormation 模板中指定 VPC 参数后查找 IGW - Lookup IGW after specifying VPC parameter in CloudFormation template 如何在 CloudFormation 中包含/引用多个资源文件? - How to Include/Reference Multiple Resource files in CloudFormation? 如何在同一个 CloudFormation 模板中声明多个相似的资源组? - How to declare multiple and similar groups of resources in the same CloudFormation template? 是否可以在 cloudformation 模板中使用多个 email 收件人创建 SNS 主题? - Is to possible to create SNS topic with multiple email Recipients in cloudformation template? cloudformation 模板中的条件标记 - Conditional tagging in cloudformation template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM