Cloud Services

Enterprise Marketplace

Fetch templates from Git repositories with authentication
Published On Jun 06, 2024 - 2:38 PM

Fetch templates from Git repositories with authentication

Describes how to set up Enterprise Marketplace so it can fetch templates from Git repositories that require authentication.
In addition to being stored in the Terraform Registry, Terraform modules can also be stored in a Git repository. Before these modules can be retrieved by Enterprise Marketplace, you need to link to the Git repository.
This feature is only available for V3 authorization tenants.
Before you can link to the GitHub repository, you need to generate a personal access token for the user that you are using to link to the repository. If you do not have access to this or have not generated it yet, then complete these steps. If you already have the token, skip to the next step.
  1. Log in to the GitHub repository using the user that you want to use to connect with, click the
    User
    icon and select
    Settings
    .
  2. On the
    Public profile
    page, click
    Developer settings
    at the bottom of the navigation pane.
  3. On the
    GitHub Apps
    page, click
    Personal access tokens
    Tokens (classic)
    .
  4. Click
    Generate new token
    Generate new token (classic)
    .
  5. On the
    New personal access token (classic)
    page, create a token with a descriptive name in the
    Note
    field and select
    repo
    as the
    scope
    .
  6. Click
    Generate token
    . Be sure to record the personal access token, as this will be the only time that it is displayed.
Create the connection using the following steps:
  1. In the Git repository, navigate to the folder where you want to retrieve the modules from and click the
    Code
    button. Select the
    HTTPS
    tab and copy the URL displayed.
  2. In the Terraform template, set
    source = “”
    parameter to the URL that you copied, for example
    source = “git::https://github.kyndryl.net/securitygroup.git”
    .
  3. Get the connection ID. To do so, navigate to
    IAM
    in the
    Admin
    section, open the connection, and copy the connection ID from the
    Connection details
    page for the connection that you want to use. The ID is displayed between
    /view/
    and
    ?type
    in the URL for the page itself. If you have not created the connection yet, you can do so by completing these steps:
    1. Navigate to
      IAM
      in the
      Admin
      section. To learn more about navigating to the different services from each tenant, refer to Landing page navigation or Kyndryl Bridge Landing page navigation.
    2. In the left navigation pane, click
      Connections
      .
    3. On the
      Connections
      page, click
      Add New
      in the upper right and select
      Add Connection
      .
    4. On the
      Add Connection
      page, enter the following parameters:
      1. Connection Name:
        Provide a descriptive name for the connection.
      2. Select Technology Category:
        Select
        Content Provider
        .
      3. Select Connection Type:
        Select
        GitHub
        .
      4. Host URL:
        Enter the URL of the GitHub repository that you want to connect to, such as
        github.kyndryl.net
        .
      5. User:
        (in the
        Credentials Details
        section)
        Enter the user name that you will use to access the GitHub repository. Use the full mail ID such as .
      6. Personal Access Token:
        Enter the GitHub access token for the user that you entered.
    5. Click
      Add
      .
  4. On the
    Connection details
    page for the connection you just created, copy the ID that is displayed between
    /view/
    and
    ?type
    in the URL for the page itself.
  5. For SP tenants only, click
    Distribute to Customer(s)
    in the upper right and select the CT tenants that you want to distribute the connection to.
  6. Open the Terraform template again and paste the connection code into the source parameter in the following format:
    source = “git::https://
    _connectionId_[CONNECTIONID}@
    github.kyndryl.net/securitygroup.git”
    , for example:
    source = "git::https://
    _connectionId_661383543639904d053d912a @
    github.kyndryl.net/MCMP-Topology/mcmp-topology-affinity-aws"
  7. Save the template.
You can now use the template to import from the Git repository using the Bring Your Own Catalog Item tool.
If the root Terraform template contains references to the modules, in order for the modules to be discovered and represented as configuration groups in the configuration management of a catalog discovered as part of the import from file action, the following steps need to be taken:
  1. The variables of the modules need to be declared in the root terraform template along with the values.
  2. Make sure to declare these variables in the modules as well and the variable references should be properly declared in the module Terraform template.
The configuration group name will be equivalent to the module name as mentioned in the root Terraform template.
Do you have two minutes for a quick survey?
Take Survey