Install and map SaaS GitLab resources in Service Catalog
Install and authorize the SaaS GitLab integration in the Konnect UI. Create a Service Catalog service and associate it with your GitLab project to display metadata and enable event tracking.
Prerequisites
Kong Konnect
If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.
- The following Konnect items are required to complete this tutorial:
- Personal access token (PAT): Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
-
Set the personal access token as an environment variable:
export KONNECT_TOKEN='YOUR KONNECT TOKEN'
Konnect roles
You need the Integration Admin role in Konnect to install and authorize Service Catalog integrations.
SaaS GitLab access
You must have a GitLab.com subscriptions and the Owner role in the GitLab group to authorize the integration. You need a project in GitLab that you want to pull in to Konnect.
Authorize the GitLab integration
- From the Service Catalog in Konnect, select Integrations.
- Click GitLab, then click Add GitLab instance.
- Select GitLab (SaaS), authorize GitLab to connect your account, and enter
gitlab
for your instance name.
Create a service in Service Catalog
Create a service that you’ll map to your GitLab resources:
curl -X POST "https://us.api.konghq.com/v1/catalog-services" \
-H "Authorization: Bearer $KONNECT_TOKEN" \
--json '{
"name": "billing",
"display_name": "Billing Service"
}'
Export the service ID:
export GITLAB_SERVICE_ID='YOUR-SERVICE-ID'
List GitLab resources
Before you can map your GitLab resources to a service in Service Catalog, you first need to find the resources that are pulled in from GitLab:
curl -X GET "https://us.api.konghq.com/v1/resources?filter%5Bintegration.name%5D=gitlab" \
-H "Authorization: Bearer $KONNECT_TOKEN"
You might need to manually sync your GitLab integration for resources to appear. From the Konnect UI by navigating to the GitLab integration you just installed and selecting Sync Now from the Actions dropdown menu.
Export the resource ID you want to map to the service:
export GITLAB_RESOURCE_ID='YOUR-RESOURCE-ID'
Map resources to a service
Now, you can map the GitLab resource to the service:
curl -X POST "https://us.api.konghq.com/v1/resource-mappings" \
-H "Authorization: Bearer $KONNECT_TOKEN" \
--json '{
"service": "billing",
"resource": "'$GITLAB_RESOURCE_ID'"
}'
Validate the mapping
To confirm that the GitLab resource is now mapped to the intended service, list the service’s mapped resources:
curl -X GET "https://us.api.konghq.com/v1/catalog-services/$GITLAB_SERVICE_ID/resources" \
-H "Authorization: Bearer $KONNECT_TOKEN"