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

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 组创建一个名为 myScalingPlan 的扩展计划,您在使用此模板启动堆栈时指定该组的名称(以及其他值)。它指定 TagFilters 属性作为应用程序源,并启用预测式扩展和动态扩展。

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":"ForecastAndScale", "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: "ForecastAndScale" PredictiveScalingMaxCapacityBehavior: "SetMaxCapacityAboveForecastCapacity" PredictiveScalingMaxCapacityBuffer: 25 ScheduledActionBufferTime: 600