After updating my main development workstation to Fedora 36 including all the tools I regularly use I noticed a change when working with Terraform code. The call to terraform init
succeeded but was accompanied by a warning:
$ terraform version -no-color Terraform v1.2.3 on linux_amd64 $ terraform init -no-color Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/oci... - Installing hashicorp/oci v4.80.1... - Installed hashicorp/oci v4.80.1 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Warning: Additional provider information from registry The remote registry returned warnings for registry.terraform.io/hashicorp/oci: - For users on Terraform 0.13 or greater, this provider has moved to oracle/oci. Please update your source in required_providers. 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.
The “What’s new” section in the OCI Terraform Provider documentation mentions this change. It also describes how to switch the provider’s source to avoid this warning.
So here is what I did. I tend to put my provider details into main.tf
, so this seemed like the best place to put the required_providers
section:
provider "oci" { tenancy_ocid = var.tenancy_ocid user_ocid = var.user_ocid fingerprint = var.key_fingerprint private_key_path = var.private_key_path private_key_password = var.private_key_password region = var.oci_region } terraform { required_providers { oci = { source = "oracle/oci" version = ">= 4.0.0" } } }
After adding the new terraform
block I managed to use the oracle/oci
provider and avoid the warning. The OCI driver version 4.80.1 was current at the time of writing.
$ terraform init -no-color Initializing the backend... Initializing provider plugins... - Finding oracle/oci versions matching ">= 4.0.0"... - Installing oracle/oci v4.80.1... - Installed oracle/oci v4.80.1 (signed by a HashiCorp partner, key ID 1533A49284137CEB) Partner and community providers are signed by their developers. If you'd like to know more about provider signing, you can read about it here: https://www.terraform.io/docs/cli/plugins/signing.html Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. 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 indeed, Terraform will now use the the oracle/oci
driver:
$ terraform version -no-color Terraform v1.2.3 on linux_amd64 + provider registry.terraform.io/oracle/oci v4.80.1
Happy automating!