Looking for an existing GitLab project cluster in Pulumi - how do I locate it?

I successfully linked a Kubernetes cluster to my Gitlab project. The cluster can be accessed at the following link: https://gitlab.com/steinKo/gitlabcicd/-/clusters/142291. Now, I'm trying to access this cluster using Pulumi. According to the documentation, I should be able to use the "Look up an Existing ProjectCluster Resource" method. Can I make an API call as well?

public static get(name: string, id: Input<ID>, state?: ProjectClusterState, opts?: CustomResourceOptions): ProjectCluster

My attempt:

import * as gitlab from "@pulumi/gitlab";

const cluster = gitlab.get("gitlabcicd", ???)

However, I encountered an error message stating that the property "get" does not exist. How can I properly utilize the "get" API? And where can I find the necessary ID?

Answer №1

To access the cluster, utilize the code snippet provided below:

import * as gitlab from "@pulumi/gitlab";

const projectCluster = gitlab.ProjectCluster.get("mycluster", "clusterid");

In this code, mycluster represents the name you assign in your Pulumi program, while clusterid refers to the GitLab ID of the cluster.

The ID of the cluster can be retrieved through the GitLab API:

It is important to note that this method only provides information about the cluster and does not allow for modifications within the Pulumi program.

If you wish to actively manage the cluster in your Pulumi program, import it using the CLI with the following command:

pulumi import gitlab:index/projectCluster:ProjectCluster bar projectid:clusterid
. This will generate the necessary code to incorporate into your Pulumi program, enabling you to take control of the cluster's management.

Answer №2

After reviewing the pulumi documentation, it seems that to fetch a project, the correct syntax would be as follows:

import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";

const example = pulumi.output(gitlab.getProject({
    id: "gitlabcicd",
}, { async: true }));

For more information, visit:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

`Managing select tag data in Angular reactive forms`

Having an issue with selecting the gender option from JSON formatted data received from the backend. The gender is displayed as a select tag on the frontend, but it does not pre-select the option that corresponds to the gender value in the JSON data. The b ...

Steps for enabling a function to return an undefined type

After extensive review, I have discovered that TypeScript has numerous hidden nuances, which make it less strict and accurate. I prefer to utilize 'undefined' as the return type for functions because it accurately reflects the reality of the sit ...

RxJS - Only emit if another source does not emit within a specified time frame

Imagine having two observables. Whenever the first one emits, there should be a 2-second pause to check if the other observable emits something within that timeframe. If it does, then no emission should occur. However, if it doesn't emit anything, the ...

What is the solution for the error message "Property 'click' does not exist on type 'never'" when working with the Next Link element?

I am working on a form that contains an input field and a submit button. The objective is to update the link href when the input changes, and then simulate a click on the link using the form's submit logic. Currently, everything seems to be functioni ...

Failure of Ngx-translate to propagate to subcomponents

Since I have implemented my translate module in the shared/header.module.ts file, it mainly serves the purpose of handling language switching for the entire application. In header.module.ts: @NgModule({ imports: [ TranslateModule.forRoot({ lo ...

The switchMap function is sending back a single item

I'm having an issue with switching the observable using the switchMap operator: return this.db.list(`UserPlaces/${this.authData.auth.auth.currentUser.uid}`, { query: { orderByChild: 'deleted', equalTo: false } }) .ma ...

Creating a Vue TypeScript component and utilizing child methods

One common issue I have encountered is trying to access a method from a child component. It usually works fine, but sometimes additional steps are needed. this.$refs.searchInput.reset() To satisfy TypeScript's requirements, you may need to do the fol ...

Utilizing external imports in webpack (dynamic importing at runtime)

This is a unique thought that crossed my mind today, and after not finding much information on it, I decided to share some unusual cases and how I personally resolved them. If you have a better solution, please feel free to comment, but in the meantime, th ...

Error in Jest: Type error - res.status function is undefined

I have implemented a middleware for token verification using the following code: import { Request, Response, NextFunction } from "express"; import jwt from "jsonwebtoken"; class TokenVerifier { public verify(req: Request, res: Resp ...

Typescript is requesting an index signature for a nested object that has been validated by Zod and is being received from an API request

This project uses Typescript 4.4.4, Next.js 11.1.2, and Zod 3.9.3. Typescript is throwing an error that says: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type <Review Type> ...

ngx-datatable Retrieve the most recent clicked row using multi-click mode

Currently, I am attempting to retrieve the most recent 'clicked' row from ngx-datatable. Here is what I have in my code: <ngx-datatable [rows]="rows" [selected]="selected" [selectionType]="'multiClick'" (select)='on ...

Utilizing Angular to Handle Undefined Variables in String Interpolation

Seeking a way to showcase data obtained from an external API on a webpage using Angular's string interpolation. If no data is retrieved or is still pending, the aim is to display 'N/A'. An attempt was made following this method, but encoun ...

``Implementing a method to save the output of an asynchronous request in a global variable for future manipulation

It's been a week and I still can't figure this out. Being new to front-end development, I'm struggling with storing the response from subscribe in a global variable for future use. ngOnInit(): void { this.http.get<APIResponse>('ur ...

Guide on how to execute jasmine tests coded in TypeScript for Node.js applications

I am eager to test my express application developed in TypeScript. I am utilizing jasmine for writing test cases, webpack for bundling TypeScript files to JavaScript, and karma as the test runner. Please locate the following files: // about.service.ts - ...

How to attach an event listener to an input element using Angular

I am looking to add a listener to an input element that will be triggered every time the user changes the input values. The goal is to display the current values chosen by the user. Example HTML template: <div id="idDoseLabel1" class="da ...

Alter the class based on the incoming string from the rxjs stream

I have a stream that outputs strings, and based on these strings I want to apply certain classes to a specific tag: If the string is "ok", add class "fa-check" If the string is "loading", add classes "fa-spin" and "fa-spinner" If the string is "error", a ...

How does Typescript handle when an RxJS Observable emits numbers but the observer.next() takes a string?

Imagine having this method within a Typescript/Angular project: subscribeSubject() { const subject = new Subject(); subject.subscribe({ next: (v1: number) => console.log('v1=',v1) }); subject.subscribe({ next: ( ...

Creating a type in Typescript where the value of an object key is expected to be of the same type as

Creating a cohesive type for cart items and their addons is essential. Both entities should share common keys: type CartItem = { productId: string name: string description: string unitPrice: number netTotal: number quantity: number taxTotals? ...

What is the best way to extract values from a specific table column and store them in an array using Angular?

I have a section of code containing a table in my component: expect-next-month.component.html <table id="users"> <tr> <th>Number of month</th> <th>Total checking e ...

Utilize regular expressions to substitute a specific string of text with an HTML tag

My task is to transform this text: let text = "#Jim, Start editing to see some magic happen!"; into this format: text = "<span style="color:red">#Jim</span>, Start editing to see some magic happen!"; Here is my ...