我正在使用
CDK
并且想使用现有集群(用于ECS)
我尝试了这个,但它显示,
错误如
Property 'fromClusterName' does not exist on type 'typeof Cluster'. Did you mean 'fromClusterArn'?
const clusterName = "mycluster"
const cluster = ecs.Cluster.fromClusterName(this, "StCluster", {
clusterName: clusterName
});
但是,我想通过
name
而不是 arn
来获取集群
我想我应该提前记下
arn
的名字?
我正在查看这个文档,没有办法通过名字获取
Cluster
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.Cluster.html
我该怎么做?
fromClusterAttributes
,但您还需要拥有集群所在的 vpc
。这是首选,因为它还可以访问 vpc
和其他属性。
const clusterName = "mycluster"
const cluster = ecs.Cluster.fromClusterAttributes(this, "iCluster", {
"vpc": myVpc,
"clusterName": clusterName
})