0
我想创建一个Opsworks stack
,其中包含Autoscaling Group
,以便可以根据费用动态添加实例。 现在,为了我的环境,00h,6h,12h和18h总是有很高的利用率。 我正在寻找一种在这些时间配置自动调节的方法:在以前的每个小时,通过Autoscaling Group
添加4个实例,其余时间只有一个实例在线。在特定时间配置自动缩放
我也跟着这Document,以便该实例从该层注销Lambda Function
。
下面是摘录:
"InstanceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"opsworks:AssignInstance",
"opsworks:DescribeInstances"
],
"Resource": [ "*" ]
}
]}
}
},
"InstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [{ "Ref": "InstanceRole" }]
}
},
"LaunchConfig": {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"AssociatePublicIpAddress" : true,
"ImageId" : { "Fn::FindInMap": ["AWSRegionToAMI", { "Ref": "AWS::Region" }, "AMIID"] },
"InstanceType" : {"Ref" : "InstanceType"},
"IamInstanceProfile": {"Ref": "InstanceProfile"},
"EbsOptimized" : true,
"SecurityGroups" : [{ "Ref" : "SG" }],
"UserData" : {
"Fn::Base64": {
"Fn::Join" : ["",
["#!/bin/bash",
"sed -i'' -e 's/.*requiretty.*//' /etc/sudoers",
"pip install --upgrade awscli",
"INSTANCE_ID=$(/usr/bin/aws opsworks register --use-instance-profile --infrastructure-class ec2 --region us-east-1 --stack-id ",
{ "Ref": "StackID"}," --override-hostname $(tr -cd 'a-z' < /dev/urandom |head -c8) --local 2>&1 |grep -o 'Instance ID: .*' |cut -d' ' -f3) /usr/bin/aws opsworks wait instance-registered --region us-east-1 --instance-id $INSTANCE_ID
/usr/bin/aws opsworks assign-instance --region us-east-1 --instance-id $INSTANCE_ID --layer-ids ",{ "Ref": "myLayer" }
]]
}
}
}
},
"AutoScalingGroup": {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"VPCZoneIdentifier": { "Ref": "subnetIds" },
"LaunchConfigurationName" : { "Ref" : "LaunchConfig"},
"LoadBalancerNames" : [{"Ref" : "ELB"}],
"MaxSize": { "Ref": "MaxSize" },
"MinSize": 1,
"Tags":
[{
"Key": "Name",
"Value": "opsworks_stack_id",
"PropagateAtLaunch": true
}],
}
},
我如何配置此类型的自动缩放的?我应该使用Time-based
吗? 任何建议,非常感谢。
你有没有考虑过使用用opsworks自动缩放? http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-autoscaling-loadbased.html http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-autoscaling.html #cwalarms – strongjz
是的,但还不够。我想我会同时使用;传统的自动缩放和基于时间的实例 – Somar