Terraform 0.13 just came out (https://www.hashicorp.com/blog/announcing-hashicorp-terraform-0-13/) and it changes how to work with 3rd party providers (https://www.terraform.io/upgrade-guides/0-13.html#explicit-provider-source-locations).
I'm encountering an error when running terraform init
:
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/ibm...
Error: Failed to install provider
Error while installing hashicorp/ibm: provider registry registry.terraform.io
does not have a provider named registry.terraform.io/hashicorp/ibm
This used to work before with Terraform 0.12.29 and the IBM provider 1.10.0.
Configuring the IBM Cloud Provider plug-in. Before you can start working with Terraform on IBM Cloud, you must retrieve the credentials and parameters that are required for a Terraform resource or data source, and specify them in the provider configuration.
Third-party provider plugins — locally installed providers, not on the registry — need to be assigned an (arbitrary) source and placed in the appropriate subdirectory for Terraform to find and use them.
A provider is a Terraform plugin that allows users to manage an external API. Provider plugins like the AWS provider or the cloud-init provider act as a translation layer that allows Terraform to communicate with many different cloud providers, databases, and services.
Here are the instructions for Linux and the current versions of Terraform and the IBM provider:
wget https://releases.hashicorp.com/terraform/0.13.0/terraform_0.13.0_linux_amd64.zip
unzip terraform_0.13.0_linux_amd64.zip
mv terraform /usr/local/bin/
terraform version
mkdir -p ~/.terraform.d/plugins/localdomain/provider/ibm/1.10.0/linux_amd64
wget https://github.com/IBM-Cloud/terraform-provider-ibm/releases/download/v1.10.0/terraform-provider-ibm_1.10.0_linux_amd64.zip
unzip terraform-provider-ibm_1.10.0_linux_amd64.zip
mv terraform-provider-ibm_v1.10.0 ~/.terraform.d/plugins/localdomain/provider/ibm/1.10.0/linux_amd64
Create main.tf
terraform {
required_providers {
ibm = {
source = "localdomain/provider/ibm"
version = "1.10.0"
}
}
}
variable ibmcloud_api_key {
}
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
}
resource ibm_resource_group new_group {
name = "created-by-terraform"
}
Create terraform.tfvars
and fill in your IBM Cloud API key:
ibmcloud_api_key="REPLACE_WITH_YOUR_KEY"
Initialize Terraform
terraform init
will result in:
Initializing the backend...
Initializing provider plugins...
- Finding localdomain/provider/ibm versions matching "1.10.0"...
- Installing localdomain/provider/ibm v1.10.0...
- Installed localdomain/provider/ibm v1.10.0 (unauthenticated)
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
And apply
terraform apply
will result in:
...
Enter a value: yes
ibm_resource_group.new_group: Creating...
ibm_resource_group.new_group: Creation complete after 2s [id=2142c8122344458d59b8729708464a]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Happy terraforming!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With