Terraform Provider Configuration

Starting from Terraform 0.13.0 a new hierarchical namespace for providers was introduced by Terraform. For more information on this refer to Terraform documentation. This new feature requires explicit source information for any providers that are not maintained by Hashicorp. Terraform 0.13.0 and above provides a new nested block required_providers inside the terraform configuration block to specify the provider source location. The value for source attribute is in the format <REGISTRY_HOST>/<NAMESPACE>/<PROVIDER_TYPE>

The starterlibrary provides the following templates that showcase how to use this new source syntax.

  • Google Cloud Single Virtual Machine Example for Terraform 1.x.x External link icon This template shows how to source the provider maintained by hashicorp and hosted in default hashicorp registry. The value hashcorp/google assigned to attribute source refers to the location of provider binary which is packaged by default under $HOME/.terraform.d/plugins/registry.terraform.io/hashicorp/google in the cam-provider-terraform pod. The name hashicorp in the source value indicates that the provider is maintained by Hashicorp. The value registry.terraform.io in the binary path refers to the default provider registry host which can be ommitted in the source value as the provider is in the default registy.

  • Virtual Server in a new VPC with SSH key For Terraform Engine 13 and 14 External link icon This template shows how to source the provider maintained by a third party vendor which in this case is IBM and hosted in default hashicorp registry. The value IBM-Cloud/ibm assigned to attribute source refers to the location of provider binary which is packaged by default under $HOME/.terraform.d/plugins/registry.terraform.io/IBM-Cloud/ibm in the cam-provider-terraform pod. The name IBM-Cloud in the source value indicates that the provider is a thrid-party provider. The value registry.terraform.io in the binary path refers to the default provider registry host which can be ommitted in the source value as the provider is in the default registry.

For the templates that use the IBM Cloud Pak for AIOps Managed services provided Terraform providers, you must use the required_providers section as shown in the following sample.

terraform {
  required_version = ">= 0.13"

  required_providers {
    camc = {
      #Source attribute value is in format <REGISTRY_HOST>/<NAMESPACE>/<PROVIDER_TYPE>
      source  = "registry.ibm.com/cam/camc"
      version = "~> 0.2"
    }
  }

}

The above sample defines the source location for IBM Cloud Pak for AIOps Managed services provided CAMC Provider. The value registry.ibm.com/cam/camc assigned to attribute source refers to the location of provider binary which is packaged under $HOME/.terraform.d/plugins/registry.ibm.com/cam/camc in the cam-provider-terraform pod. The name registry.ibm.com/cam in the source value indicates that the provider is a IBM Cloud Pak for AIOps Managed services provided provider. The value registry.ibm.com in the binary path refers to a local dummy non-existent domain to indicate that this provider is a local in-house provider.

For a different IBM Cloud Pak for AIOps Managed services provided provider say UCD provider, you would change only the value for PROVIDER_TYPE as shown below.

terraform {
  required_version = ">= 0.13"

  required_providers {
    ucd = {
      #Source attribute value is in format <REGISTRY_HOST>/<NAMESPACE>/<PROVIDER_TYPE>
      source  = "registry.ibm.com/cam/ucd"
      version = "~> 0.5"
    }
  }

}

Refer to Shipped Terraform providers for complete set of provider binaries (which are compatiable with Terraform 0.13.0 or higher) bundled with IBM Cloud Pak for AIOps Managed services.