Install and map GitHub resources in Service Catalog

Uses: Service Catalog Konnect API
Related Documentation
Incompatible with
on-prem
TL;DR

Install the GitHub integration in Konnect and authorize access to one or more repositories, then link a repository to your service to display metadata and enable event tracking.

Prerequisites

If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.

  1. 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.
  2. Set the personal access token as an environment variable:

    export KONNECT_TOKEN='YOUR KONNECT TOKEN'
    

You need the Integration Admin role in Konnect to install and authorize Service Catalog integrations.

To integrate GitHub with Service Catalog, you need the following:

  • Sufficient permissions in GitHub to authorize third-party applications and install the Konnect GitHub App
  • A GitHub organization
  • A repository that you want to pull in to Konnect. You can grant access to either all repositories or selected repositories during the authorization process.

The Konnect app can be managed in your GitHub account under Applications > GitHub Apps.

Install and authorize the GitHub integration

  1. From the Service Catalog in Konnect, select Integrations.
  2. Click GitHub, then click Add GitHub Instance.
  3. Authorize the GitHub integration. This will take you to GitHub, where you can grant Konnect access to either All Repositories or Select repositories.
  4. Enter github as your instance name.

The Konnect application can be managed from GitHub as a GitHub Application.

Create a service in Service Catalog

Create a service that you’ll map to your GitHub 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 GITHUB_SERVICE_ID='YOUR-SERVICE-ID'

List GitHub resources

Before you can map your GitHub resources to a service in Service Catalog, you first need to find the resources that are pulled in from GitHub:

 curl -X GET "https://us.api.konghq.com/v1/resources?filter%5Bintegration.name%5D=github" \
     -H "Authorization: Bearer $KONNECT_TOKEN"

You might need to manually sync your GitHub integration for resources to appear. From the Konnect UI by navigating to the GitHub 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 GITHUB_RESOURCE_ID='YOUR-RESOURCE-ID'

Map resources to a service

Now, you can map the GitHub resource to the service:

 curl -X POST "https://us.api.konghq.com/v1/resource-mappings" \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "service": "billing",
       "resource": "'$GITHUB_RESOURCE_ID'"
     }'

Validate the mapping

To confirm that the GitHub 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/$GITHUB_SERVICE_ID/resources" \
     -H "Authorization: Bearer $KONNECT_TOKEN"
Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!