Repost my topic, could someone point out which API...
# general
f
Repost my topic, could someone point out which API I should use in Pulumi to achieve following goals? We have a business requirement for following steps 1. List all EKS clusters existing on the AWS cloud, and get their name/id 2. Check the cluster status by passing the cluster name/id. 3. Get provider instance by passing the cluster name/id
l
Hello @fancy-xylophone-7581, I ’ll try to answer as close as possible to your questions with pointers to our documentation. Feel free to ask subsequent questions if it is not clear. 1. https://www.pulumi.com/registry/packages/aws/api-docs/eks/getclusters/ which gives you a list of names. Loop over the names, calling https://www.pulumi.com/registry/packages/aws/api-docs/eks/getcluster/ which gives you more detailed info about a cluster. 2. From the previous detailed cluster result, use the
status
output: https://www.pulumi.com/registry/packages/aws/api-docs/eks/getcluster/#status_nodejs 3. compute the
kubeconfig
which you can pass to the
kubernetes.Provider
class similar to what we do in our EKS component: https://github.com/pulumi/pulumi-eks/blob/1884c3ce7bf362d5ab80eccc2ed4523cac348020/nodejs/eks/cluster.ts#L571-L589
f
Many thanks for the help, I will dig into them.
@limited-rainbow-51650 Thanks again, one more question, How could I get the instance of eks.Cluster from id / name / arn? If I can get the instance of that cluster, the step 3 would be much easier by get the field cluster.provider.
l
@fancy-xylophone-7581 doesn’t the detailed cluster info from step 2 contain all the information you need to calculate the kubeconfig?
f
@limited-rainbow-51650 It call a private overloaded functions generateKubeconfig to pass these parameters, and it is ugly design to duplicate these codes and if your source updated, my code would be outdated and lead to potential bug. Is there an exposed API that I can get the instance of Provider or Cluster Instance instead of code duplication?
@limited-rainbow-51650 I thought about the requirement last evening, I think that my question is actually: could I create a Pulumi Cluster Object from existing one on the AWS EKS? Or if this cluster is also provisioned by Pulumi, could I create an eks.Cluster instance of it in my local environment.
Just let me know if it is not possible, I can find an alternative way instead. Thanks a lot for your support.
l
No, retrieving info on existing resources is done via the
getXXXX
functions you see in the provider SDKs. If you use the classes and instantiate them, it indicates that you want Pulumi to create and manage one for you.
f
For more clarification. here is a case: I have 2 stacks, stack 1 provision the a EKS cluster A and stack 2 provision Helm chart and Kubernetes things. Is it possible stack 2 create a Cluster A instance locally which is identical with the cluster instance in stack 1?