gpt4 book ai didi

amazon-web-services - 使用 CloudFormation 和 AWS 控制台创建 ECS 集群时的不同行为

转载 作者:行者123 更新时间:2023-12-03 07:25:34 25 4
gpt4 key购买 nike

使用CloudFormation创建时,没有缩放ECS实例按钮,要缩放实例,您需要找到Auto Scaling Group到缩放不是我想要的实例。

enter image description here

使用AWS 控制台创建时,有一个扩展 ECS 实例按钮。

enter image description here

我想在使用 CloudFormation 创建时有该按钮。

我错过了什么或者做错了什么吗?

{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"Create ECS Cluster, ECS Task Definitions, Lambdas, CloudWatchs for different country and environment.",
"Parameters":{
"CountryName":{
"Type":"String",
"Description":"Auto inclusion launch country name.",
"AllowedValues":[
"my",
"sg"
]
},
"EnvironmentName":{
"Type":"String",
"Description":"An environment name that will be suffixed to resource names.",
"AllowedValues":[
"dev",
"stage",
"live"
]
},
"KeyName":{
"Type":"AWS::EC2::KeyPair::KeyName",
"Description":"Name of an existing EC2 KeyPair to enable SSH access to the ECS instance."
},
"VpcId":{
"Type":"AWS::EC2::VPC::Id",
"Description":"Select a VPC to deploy the ECS instance."
},
"SubnetId":{
"Type":"List<AWS::EC2::Subnet::Id>",
"Description":"Select at least two subnets in your selected VPC to deploy the ECS instance."
},
"InstanceType":{
"Description":"ECS instance type",
"Type":"String",
"Default":"t2.micro",
"AllowedValues":[
"t2.micro",
"t2.small",
"t2.medium",
"t2.large",
"m3.medium",
"m3.large",
"m3.xlarge",
"m3.2xlarge",
"m4.large",
"m4.xlarge",
"m4.2xlarge",
"m4.4xlarge",
"m4.10xlarge",
"c4.large",
"c4.xlarge",
"c4.2xlarge",
"c4.4xlarge",
"c4.8xlarge",
"c3.large",
"c3.xlarge",
"c3.2xlarge",
"c3.4xlarge",
"c3.8xlarge",
"r3.large",
"r3.xlarge",
"r3.2xlarge",
"r3.4xlarge",
"r3.8xlarge",
"i2.xlarge",
"i2.2xlarge",
"i2.4xlarge",
"i2.8xlarge"
],
"ConstraintDescription":"Please choose a valid instance type."
}
},
"Mappings":{
"AWSRegionToAMI":{
"us-east-1":{
"AMIID":"ami-a7a242da"
},
"us-east-2":{
"AMIID":"ami-b86a5ddd"
},
"us-west-1":{
"AMIID":"ami-9ad4dcfa"
},
"us-west-2":{
"AMIID":"ami-92e06fea"
},
"eu-west-1":{
"AMIID":"ami-0693ed7f"
},
"eu-west-2":{
"AMIID":"ami-f4e20693"
},
"eu-west-3":{
"AMIID":"ami-698b3d14"
},
"eu-central-1":{
"AMIID":"ami-0799fa68"
},
"ap-northeast-1":{
"AMIID":"ami-68ef940e"
},
"ap-northeast-2":{
"AMIID":"ami-a5dd70cb"
},
"ap-southeast-1":{
"AMIID":"ami-0a622c76"
},
"ap-southeast-2":{
"AMIID":"ami-ee884f8c"
},
"ca-central-1":{
"AMIID":"ami-5ac94e3e"
},
"ap-south-1":{
"AMIID":"ami-2e461a41"
},
"sa-east-1":{
"AMIID":"ami-d44008b8"
}
}
},
"Resources":{
"ECSCluster":{
"Type":"AWS::ECS::Cluster",
"Properties":{
"ClusterName":{
"Fn::Join":[
"-",
[
{
"Ref":"AWS::StackName"
},
{
"Ref":"EnvironmentName"
}
]
]
}
}
},
"ECSSecurityGroup":{
"Type":"AWS::EC2::SecurityGroup",
"Properties":{
"GroupDescription":"Auto Inclusion Security Group",
"VpcId":{
"Ref":"VpcId"
}
}
},
"ECSSecurityGroupSSHinbound":{
"Type":"AWS::EC2::SecurityGroupIngress",
"Properties":{
"GroupId":{
"Ref":"ECSSecurityGroup"
},
"IpProtocol":"tcp",
"FromPort":"22",
"ToPort":"22",
"CidrIp":"0.0.0.0/0"
}
},
"ECSAutoScalingGroup":{
"Type":"AWS::AutoScaling::AutoScalingGroup",
"Properties":{
"VPCZoneIdentifier":{
"Ref":"SubnetId"
},
"LaunchConfigurationName":{
"Ref":"ECSLaunchConfiguration"
},
"MinSize":"0",
"MaxSize":"1",
"DesiredCapacity":"1"
}
},
"ECSLaunchConfiguration":{
"Type":"AWS::AutoScaling::LaunchConfiguration",
"Properties":{
"ImageId":{
"Fn::FindInMap":[
"AWSRegionToAMI",
{
"Ref":"AWS::Region"
},
"AMIID"
]
},
"InstanceType":{
"Ref":"InstanceType"
},
"IamInstanceProfile":{
"Ref":"EC2InstanceProfile"
},
"KeyName":{
"Ref":"KeyName"
},
"SecurityGroups":[
{
"Ref":"ECSSecurityGroup"
}
],
"UserData":{
"Fn::Base64":{
"Fn::Join":[
"",
[
"#!/bin/bash\n",
"echo ECS_CLUSTER=",
{
"Ref":"ECSCluster"
},
" >> /etc/ecs/ecs.config"
]
]
}
}
}
},
"EC2Role":{
"Type":"AWS::IAM::Role",
"Properties":{
"AssumeRolePolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":[
"ec2.amazonaws.com"
]
},
"Action":[
"sts:AssumeRole"
]
}
]
},
"Path":"/",
"ManagedPolicyArns":[
"arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
],
"Policies":[
{
"PolicyName":"auto-inclusion",
"PolicyDocument":{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":[
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource":[
"*"
]
},
{
"Effect":"Allow",
"Action":[
"dynamodb:*"
],
"Resource":[
{
"Fn::Join":[
"",
[
"arn:aws:dynamodb:",
{
"Ref":"AWS::Region"
},
":",
{
"Ref":"AWS::AccountId"
},
":table/ai-process-tracking-",
{
"Ref":"EnvironmentName"
}
]
]
}
]
}
]
}
}
]
}
},
"EC2InstanceProfile":{
"Type":"AWS::IAM::InstanceProfile",
"Properties":{
"Path":"/",
"Roles":[
{
"Ref":"EC2Role"
}
]
}
}
},
"Outputs":{
"ecscluster":{
"Value":{
"Ref":"ECSCluster"
}
}
}
}

最佳答案

更新:我在官方documentation找到了这个。

If your cluster was created with the console first-run experience after November 24th, 2015, then the Auto Scaling group associated with the AWS CloudFormation stack created for your cluster can be scaled up or down to add or remove container instances. You can perform this scaling operation from within the Amazon ECS console.

If your cluster was not created with the console first-run experience after November 24th, 2015, then you cannot scale your cluster from the Amazon ECS console. However, you can still modify existing Auto Scaling groups associated with your cluster in the Auto Scaling console.


引用号:Scaling Cluster

If a Scale ECS Instances button appears, then you can scale your cluster in the next step. If not, you must manually adjust your Auto Scaling group to scale up or down your instances, or you can manually launch or terminate your container instances in the Amazon EC2 console.

关于amazon-web-services - 使用 CloudFormation 和 AWS 控制台创建 ECS 集群时的不同行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49281877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com