AWS::AutoScalingPlans::ScalingPlan - AWS CloudFormation
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS::AutoScalingPlans::ScalingPlan

AWS::AutoScalingPlans::ScalingPlan 资源定义了一个扩展计划,AWS Auto Scaling 使用该计划扩展以下应用程序资源:

  • Amazon EC2 Auto Scaling 组

  • Amazon EC2 Spot 队列请求

  • Amazon ECS 服务

  • Amazon DynamoDB 表和全局二级索引

  • Amazon Aurora 副本

有关更多信息,请参阅 AWS Auto Scaling 用户指南

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::AutoScalingPlans::ScalingPlan", "Properties" : { "ApplicationSource" : ApplicationSource, "ScalingInstructions" : [ ScalingInstruction, ... ] } }

YAML

Type: AWS::AutoScalingPlans::ScalingPlan Properties: ApplicationSource: ApplicationSource ScalingInstructions: - ScalingInstruction

属性

ApplicationSource

一个 CloudFormation 堆栈或一组标签。您可以为每个应用程序源创建一个扩展计划。ApplicationSource 属性必须存在,以确保与 AWS Auto Scaling 控制台的互操作性。

必需:是

类型ApplicationSource

Update requires: No interruption

ScalingInstructions

扩展说明。

必需:是

类型ScalingInstruction 的列表

Update requires: No interruption

返回值

Ref

如果将 AWS::AutoScalingPlans::ScalingPlan 资源的逻辑 ID 传递给内部 Ref 函数,该函数将返回扩展计划的 Amazon 资源名称 (ARN)。ARN 的格式如下所示:

arn:aws:autoscaling:region:123456789012:scalingPlan:scalingPlanName/plan-name:scalingPlanVersion/plan-version

有关使用 Ref 函数的更多信息,请参阅 Ref

示例

扩展计划

以下示例为现有 Auto Scaling 组 (AWS::AutoScaling::AutoScalingGroup) 创建一个名为 myScalingPlan 的扩展计划,您在使用此模板启动堆栈时指定该组的名称。它将 TagFilters 属性指定为应用程序源。只要密钥对对于每个扩展计划都是唯一的,就可以指定您所需的任何标签键和标签值而不影响堆栈。这可以是您选择的任何值,可帮助您识别扩展计划配置。但是,如果您还想使用 AWS Auto Scaling 控制台编辑扩展计划,则标签必须与您为 Auto Scaling 组选择的标签匹配。

ScalingInstructions 属性包含启用预测式扩展和动态扩展所需的信息。在此示例中,预测式扩展模式指定 ForecastOnly。在这种情况下,AWS Auto Scaling 会生成带有未来两天流量预测的预测,但不会安排扩展操作来匹配预测。

JSON

{ "AWSTemplateFormatVersion":"2010-09-09", "Parameters":{ "myTagKey":{ "Type":"String" }, "myTagValue":{ "Type":"String" }, "myASGroup":{ "Type":"String", "Description":"Name of the Auto Scaling group" }, "ASGMinCapacity":{ "Type":"Number" }, "ASGMaxCapacity":{ "Type":"Number" }, "ASGTargetUtilization":{ "Type":"Number", "Default":"50.0" }, "ASGEstimatedInstanceWarmup":{ "Type":"Number", "Default":"600" } }, "Resources":{ "myScalingPlan":{ "Type":"AWS::AutoScalingPlans::ScalingPlan", "Properties":{ "ApplicationSource":{ "TagFilters":[ { "Key":{ "Ref":"myTagKey" }, "Values":[{ "Ref":"myTagValue" }] } ] }, "ScalingInstructions":[ { "MinCapacity":{ "Ref":"ASGMinCapacity" }, "MaxCapacity":{ "Ref":"ASGMaxCapacity" }, "ServiceNamespace":"autoscaling", "ScalableDimension":"autoscaling:autoScalingGroup:DesiredCapacity", "ResourceId":{ "Fn::Join":[ "/", [ "autoScalingGroup", { "Ref":"myASGroup" } ] ] }, "TargetTrackingConfigurations":[ { "PredefinedScalingMetricSpecification":{ "PredefinedScalingMetricType":"ASGAverageCPUUtilization" }, "TargetValue":{ "Ref":"ASGTargetUtilization" }, "EstimatedInstanceWarmup":{ "Ref":"ASGEstimatedInstanceWarmup" } } ], "PredefinedLoadMetricSpecification":{ "PredefinedLoadMetricType":"ASGTotalCPUUtilization" }, "PredictiveScalingMode":"ForecastOnly", "PredictiveScalingMaxCapacityBehavior":"SetMaxCapacityAboveForecastCapacity", "PredictiveScalingMaxCapacityBuffer":25, "ScheduledActionBufferTime":600 } ] } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Parameters: myTagKey: Type: String myTagValue: Type: String myASGroup: Type: String Description: Name of the Auto Scaling group ASGMinCapacity: Type: Number ASGMaxCapacity: Type: Number ASGTargetUtilization: Type: Number Default: 50.0 ASGEstimatedInstanceWarmup: Type: Number Default: 600 Resources: myScalingPlan: Type: AWS::AutoScalingPlans::ScalingPlan Properties: ApplicationSource: TagFilters: - Key: !Ref myTagKey Values: - !Ref myTagValue ScalingInstructions: - MinCapacity: !Ref ASGMinCapacity MaxCapacity: !Ref ASGMaxCapacity ServiceNamespace: autoscaling ScalableDimension: autoscaling:autoScalingGroup:DesiredCapacity ResourceId: !Join - / - - autoScalingGroup - !Ref myASGroup TargetTrackingConfigurations: - PredefinedScalingMetricSpecification: PredefinedScalingMetricType: "ASGAverageCPUUtilization" TargetValue: !Ref ASGTargetUtilization EstimatedInstanceWarmup: !Ref ASGEstimatedInstanceWarmup PredefinedLoadMetricSpecification: PredefinedLoadMetricType: "ASGTotalCPUUtilization" PredictiveScalingMode: "ForecastOnly" PredictiveScalingMaxCapacityBehavior: "SetMaxCapacityAboveForecastCapacity" PredictiveScalingMaxCapacityBuffer: 25 ScheduledActionBufferTime: 600