Importing a template

You can import a template from your Git repository.

About the task

By default, templates that are imported from Git repositories are not tagged to any namespace and are globally accessible. You can create a clone of the template and then associate a namespace to it.

Procedure

  1. In the navigation bar, click Library > Terraform templates. The template library is displayed.
  2. Click Import template.
  3. For GitHub, GitLab, and Bitbucket Server, select either of the following options in Assign access* section:

    • Make template globally accessible (available to all users) - Templates created globally are accessible by all users.
    • Make template part of a namespace - Associate the template with a specific namespace. For this option, you must select a Namespace from the drop-down list to which the template must be assigned.

    Note:

    • If you create a template in a specific namespace, then only deployments to that namespace can use the template.
    • Based on the value selected in the namespace drop-down list of the Library > Terraform templates main page, the Assign access and Namespace values are automatically selected. You can modify those values.
  4. From Import template source drop-down list, select any of the following values:

    • GitHub
    • GitLab
    • Bitbucket server
    • From scratch
    • From URL (.zip file)
    • From folder
    • From file(*.zip)
  5. Enter the following details of your selected repository:

    • For GitLab or GitHub, enter a repository URL, an access token, the relative directory of your service, and the related branch.

      • GitHub repository URL - https://github.com/geekbass/terraform

        Note: URL parsing is not possible if there exists "/" in branch name as it is not possible to differentiate between sub-directory and branch. You can still use the "/" but must manually update the fields after they are auto-parsed.

      • GitHub access token- It is the token required to access GitHub template files. You can find it in your GitHub user account, and is not required for public projects.
      • GitHub repository download directory- The path relative to GitHub project location where Terraform template files for this template can be referenced. vsphere.
      • GitHub repository template run directory- Optional field, the path relative to the GitHub download folder. The Terraform template runs from this folder.
      • GitHub reference (branch or tag)- The default value for branch or tag reference is master, however, you can change the value.
    • For Bitbucket server, enter the following details:

      • Bitbucket repository URL - The location where Bitbucket template files can be referenced from.

        Note: URL parsing is not possible if there exists "/" in branch name as it is not possible to differentiate between sub-directory and branch. You can still use the "/" but must manually update the fields after they are auto-parsed.

      • Bitbucket access token - The token used to access the Bitbucket template files
      • Bitbucket repository download directory - Optional field, the path relative to the Bitbucket server download folder. The Terraform template runs from this folder.
      • Bitbucket repository template run directory- Optional field, the path relative to the Bitbucket server download folder. The Terraform template runs from this folder.
      • Bitbucket reference - Select Branch or Tag option and enter the name of the tag or branch.
    • For From scratch, enter the following details:

      • Name - The name of the template.
      • Description - The description of the template.
      • Cloud providers - Select the cloud provider for the template.

        Note:

        • The template name must have a combination of only these characters: [a-zA-Z][a-zA-Z0-9_-]
        • For information about the available cloud providers, see Managing connections. If your cloud provider is not in the drop-down list, then select Other option. The created template is added to My templates in the library page.
        • The template can be associated with more than one provider.
    • For From URL (.zip file), enter the following details:

      • Name - Optionally, enter the name of the template. This name overwrites the template name that is found in the repository.
      • URL - The location of the zip file (http/https) where the compressed template files can be referenced from. For example, "http://myserver.com/templates/template1.zip".
      • Template run directory - Optional field, the sub-folder of the zip file. The Terraform template runs from this folder.
      • Artifactory API Key - Optionally, if your .zip file URL is an artifactory location, then enter the artifactory API key.
    • For From Folder, enter the following details:

      • Name - The name of the template.
      • Choose folder - The directory containing the template source code.
      • Template run directory - Optional field, the sub-folder of the uploaded folder. The Terraform template runs from this folder.
    • For From file(*.zip), enter the following details:

      • Name - The name of the template.
      • Choose file(*.zip) - The zip archive containing the template source code.
      • Template run directory - Optional field, the sub-folder of the uploaded folder. The Terraform template runs from this folder.
  6. Click Import.

  7. In the Template metadata tab, you can enter or change the template name, icon, short description, cloud provider, and details as a long description or the list of features.
  8. In the Manage template tab, you can manage the template versions and the template parameters. If you are creating a template from scratch, in the Edit version tab, add your template source code by importing it from a file or from a URL. In the Edit version tab, click Update parameters to add parameters from the template source or from a file. For information about using Managed services Variables, see Template Middleware Parameters.

    For information about running a local executable after a resource is created during the deployment, see local-exec provisioner External link icon.

  9. You can add new version of the template or delete an existing one by clicking the Manage versions tab. You can also edit an existing version, disable it, or set it as default by clicking the appropriate action in the overflow menu of the ACTIONS column.

    The template version follows major.minor.patch convention, where:

    • major refers to significant changes
    • minor refers to new features added but existing functionality remains broadly compatible
    • patch refers to bug fixes

    Note:

    • If you want to define the name of the stack instance in your Terraform template, you do not need to define a Managed services variables or a parameter but you can use the input variable named ibm_stack_name that is filled out automatically during the deployment with the name of the stack instance.

    • The character period (.) is not supported in the map name of the template parameters and shared parameters. Example of a map name with a period (.) that is not supported:

       {
        "my.key1": "myhostname"
       }
      

      It causes an internal server error. However, you can use the period (.) in the map value. Example of a map value with a period (.) that is supported:

       {
        "mykey": "myhostname.com"
       }
      
  10. Click Save to save your template in the library.

    Note: If you created templates with a previous version of Managed services, be aware that the resource names for the IBM Cloud provider were changed. For more information, see Migrating to v0.4 External link icon.

From the overflow menu of a template, you can perform the following actions: