I am using CDK and would like to use the exist cluster(for ECS)
I try this, however it shows,
error such as 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
});
Yet, I want to get the cluster by name not arn
I guess I should take arn by name in advance?
I am cheking this document, there is no method to get Cluster by name
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.Cluster.html
How can I do this?
You can use
fromClusterAttributesbut you will also need to have thevpcthe cluster is in. You can import it if you know thevpc id.fromClusterAttributesis preferred overfromClusterArnas it also gives access to thevpcand other properties.