I have connected a Kubernetes cluster in Gitlab as a project cluster https://gitlab.com/steinKo/gitlabcicd/-/clusters/142291 I want to acsess this cluster in Pulumi Folow thw dcumentaion can I use Look up an Existing ProjectCluster Resource Could I use the API call
public static get(name: string, id: Input<ID>, state?: ProjectClusterState, opts?: CustomResourceOptions): ProjectCluster
I wrote
import * as gitlab from "@pulumi/gitlab";
const cluster = gitlab.get("gitlabcicd", ???)
Then I get an errormessage : Property get dose not exit How do I use get API? Where do I find the id?
Reading the pulumi docs looks like in order to retrieve project the right syntax would be:
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const example = pulumi.output(gitlab.getProject({
id: "gitlabcicd",
}, { async: true }));
Reference: https://www.pulumi.com/docs/reference/pkg/gitlab/getproject/
You can get access to the cluster using the following code:
import * as gitlab from "@pulumi/gitlab";
const projectCluster = gitlab.ProjectCluster.get("mycluster", "clusterid");
where mycluster
is the name you're giving it in your Pulumi program and clusterid
is the ID in GitLab of the cluster.
You can get the ID of the cluster using the GitLab API: https://docs.gitlab.com/ee/api/project_clusters.html
Please note that this will not allow you to make changes to the cluster (as you're not importing it into the Pulumi program), but it will give you information about the cluster itself.
If you wanted to start managing the cluster in your Pulumi program, then you can import it using the CLI by running this command: pulumi import gitlab:index/projectCluster:ProjectCluster bar projectid:clusterid
which will give you the correct code to copy and paste into your Pulumi program at which point you can start managing it.