繁体   English   中英

创建容量提供程序时出现 AWS ECS 错误

[英]AWS ECS Error When Creating Capacity Provider

我正在尝试通过 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)

当我运行部署以创建所有 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)

有谁知道我需要做些什么来阻止这个无效名称错误的出现? 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. 任何帮助将不胜感激,谢谢。

确保您的堆栈名称不以 ecs、aws 或 fargate 开头。 此错误在 cdk examples repo issue中报告。 更改堆栈名称时已修复。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM