英文:
AWS ECS Error When Creating Capacity Provider
问题
我正在尝试通过Golang AWS CDK创建一个容量提供者:
cluster := awsecs.NewCluster(stack, jsii.String("ecsCluster"), &awsecs.ClusterProps{
Vpc: vpc,
EnableFargateCapacityProviders: newTrue(),
})
// 创建要附加到集群的自动扩缩容组。
autoScalingGroup := autoscaling.NewAutoScalingGroup(stack, jsii.String("ASG"), &autoscaling.AutoScalingGroupProps{
Vpc: vpc,
InstanceType: ec2.NewInstanceType(jsii.String("t2.micro")),
MachineImage: ecs.EcsOptimizedImage_AmazonLinux2(),
MinCapacity: jsii.Number(0),
MaxCapacity: jsii.Number(100),
})
autoScalingGroup.ScaleOnCpuUtilization(jsii.String("CpuScaling"), &autoscaling.CpuUtilizationScalingProps{
TargetUtilizationPercent: jsii.Number(90),
})
capacityProvider := ecs.NewAsgCapacityProvider(stack, jsii.String("myCapProvider"), &ecs.AsgCapacityProviderProps{
AutoScalingGroup: autoScalingGroup,
})
cluster.AddAsgCapacityProvider(capacityProvider)
当我运行部署以创建所有AWS资源时,我会遇到容量提供者的错误:
3:39:39 PM | CREATE_FAILED | AWS::ECS::CapacityProvider
| myCapProvider/myCapProvider
Resource handler returned message: "Invalid request provided: CreateCapacityPro
vider error: The specified capacity provider name is invalid. Up to 255 charact
ers are allowed, including letters (upper and lowercase), numbers, underscores,
and hyphens. The name cannot be prefixed with "aws", "ecs", or "fargate". Speci
fy a valid name and try again. (Service: AmazonECS; Status Code: 400; Error Cod
e: ClientException; Request ID: azz1be40-53q6-452c-n080-l9676s851o39; Proxy: nu
ll)" (RequestToken: f4z2s97k-9w42-5198-236b-bdbfcf1dac83, HandlerErrorCode: Inv
alidRequest)
有人知道我需要做什么来防止出现这个无效名称错误吗?
我查看了Go文档- https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdk/awsecs#NewAsgCapacityProvider,但它使用的格式与我使用的相同。非常感谢任何帮助。
英文:
I am trying to create a Capacity Provider via Golang AWS CDK:
cluster := awsecs.NewCluster(stack, jsii.String("ecsCluster"), &awsecs.ClusterProps{
Vpc: vpc,
EnableFargateCapacityProviders: newTrue(),
})
//Creating auto scaling group to attach to cluster
autoScalingGroup := autoscaling.NewAutoScalingGroup(stack, jsii.String("ASG"), &autoScalingGroupProps{
vpc: vpc,
instanceType: ec2.NewInstanceType(jsii.String("t2.micro")),
machineImage: ecs.ecsOptimizedImage.amazonLinux2(),
minCapacity: jsii.Number(0),
maxCapacity: jsii.Number(100),
})
autoScalingGroup.scaleOnCpuUtilization(jsii.String("CpuScaling"), &cpuUtilizationScalingProps{
targetUtilizationPercent: jsii.Number(90),
})
capacityProvider := ecs.NewAsgCapacityProvider(stack, jsii.String("myCapProvider"), &asgCapacityProviderProps{
autoScalingGroup: autoScalingGroup,
})
cluster.addAsgCapacityProvider(capacityProvider)
When I run deploy to create all the AWS resources I am getting this error for the capacity provider:
3:39:39 PM | CREATE_FAILED | AWS::ECS::CapacityProvider
| myCapProvider/myCapProvider
Resource handler returned message: "Invalid request provided: CreateCapacityPro
vider error: The specified capacity provider name is invalid. Up to 255 charact
ers are allowed, including letters (upper and lowercase), numbers, underscores,
and hyphens. The name cannot be prefixed with "aws", "ecs", or "fargate". Speci
fy a valid name and try again. (Service: AmazonECS; Status Code: 400; Error Cod
e: ClientException; Request ID: azz1be40-53q6-452c-n080-l9676s851o39; Proxy: nu
ll)" (RequestToken: f4z2s97k-9w42-5198-236b-bdbfcf1dac83, HandlerErrorCode: Inv
alidRequest)
Does anyone know what I need to do to stop this invalid name error from appearing?
I looked at the Go documentation at - https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdk/awsecs#NewAsgCapacityProvider but it is using the same format I am using. Any help would be greatly appreciated, thanks.
答案1
得分: 1
确保您的堆栈名称不以ecs、aws或fargate开头。此错误在cdk示例存储库的问题报告中被提到(链接)。当堆栈名称更改后,问题得到了修复。
英文:
Make sure your stack name doesnt start with ecs, aws, or fargate.
This error was reported in cdk examples repo issue. It was fixed when stack name was changed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论