简体   繁体   English

AWS Cloudformation 模板条件和自动扩展配置

[英]AWS Cloudformation template conditions and autoscaling config

I am writing my first AWS Cloudformation template in Yaml.我正在用 Yaml 编写我的第一个 AWS Cloudformation 模板。 I am trying to figure out if it is possible to specify the number of instances created by an Autoscaling group based on two separate parameter inputs.我试图弄清楚是否可以根据两个单独的参数输入来指定自动缩放组创建的实例数。

Example: User enters the volume of data indexed in GB from 1 to 3072 and it is saved as "data volume" parameter.示例:用户输入以 GB 为单位索引的数据量,从 1 到 3072,并保存为“数据量”参数。 Then the user enters the number of users of the network up to and it is saved as "usernumber".然后用户输入网络的用户数,保存为“usernumber”。 I then want to used to tell the ASG how many instances to create.然后我想用来告诉 ASG 要创建多少个实例。 So if there are 16 users and 2gb of data volume I want 2 instances and if there are 48 users and 500gb of data volume i want 10 instances and so on up to 21 instances.因此,如果有 16 个用户和 2GB 的数据量,我想要 2 个实例,如果有 48 个用户和 500GB 的数据量,我想要 10 个实例,依此类推,最多 21 个实例。

Is something like this possible?这样的事情可能吗? Or am I stuck with only being able to allow the user to enter the number that they want as a single parameter?或者我是否坚持只能允许用户输入他们想要的数字作为单个参数?

Thanks for any help.谢谢你的帮助。

Is something like this possible?这样的事情可能吗?

You could probably create a number of conditions in CFN , to account for all possible combinations .您可能可以在 CFN 中创建许多条件,以说明所有可能的组合 If you have only few allowed combinations, its should be doable.如果你只有几个允许的组合,它应该是可行的。

For anything more complex, you need custom resource .对于任何更复杂的事情,您需要自定义资源 The resource would be in the form of a lambda function which could do any calculatons on your parameters and and launch your instance using AWS SDK.该资源将采用lambda 函数的形式,它可以对您的参数进行任何计算,并使用 AWS 开发工具包启动您的实例。

Here is an example of what I am trying to write这是我正在尝试编写的示例

Create2Indexer: !And - !Equals - !Ref 'NumberofUsers' - <= '8' - !Equals - !Ref 'DailyIndexVolume' - '>=300' - !Equals - !Ref 'DailyIndexVolume' - < '600' !OR !AND - !Equals - !Ref 'NumberofUsers' - > '16' - !Equals - !Ref 'DailyIndexVolume' - < '300' Create2Indexer: !And - !Equals - !Ref 'NumberofUsers' - <= '8' - !Equals - !Ref 'DailyIndexVolume' - '>=300' - !Equals - !Ref 'DailyIndexVolume' - < '600' !OR !AND - !Equals - !Ref 'NumberofUsers' - > '16' - !Equals - !Ref 'DailyIndexVolume' - < '300'

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

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