When trying to provision resources for an application in an AWS Beanstalk einvironment with terragrunt, it gives:
Initializing modules...
- module.db
- module.db.db_subnet_group
- module.db.db_parameter_group
- module.db.db_option_group
- module.db.db_instance
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...
Provider "tfstate" not available for installation.
A provider named "tfstate" could not be found in the official repository.
This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.
terragrunt version v0.18.7
Terraform v0.11.14
Related
When I ran init:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
Finding cloudflare/cloudflare versions matching "~> 3.0"...
Finding latest version of hashicorp/cloudflare...
Installing cloudflare/cloudflare v3.31.0...
Installed cloudflare/cloudflare v3.31.0 (signed by a HashiCorp partner, key ID DE413CEC881C3283)
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
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/cloudflare: provider registry registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/cloudflare
Did you intend to use cloudflare/cloudflare? If so, you must specify that source address in each module which requires that provider. To see which modules are currently
depending on hashicorp/cloudflare, run the following command:
terraform providers
Module:
cat dns.tf
module "dns" {
source = "./dns"
}
Definition:
cat cloudflare.tf
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
}
provider "cloudflare" {
email = "CLOUDFLARE_EMAIL"
api_key = "CLOUDFLARE_API_KEY"
}
[ocidev#TFmgtServerv2 dev]$ ./init.sh -upgrade
******** iad ***************************
/home/ocidev/ws/oraclegbudev/src/oci-admin/environments/dev/iad
******** network ***********************
/home/ocidev/ws/oraclegbudev/src/oci-admin/environments/dev/iad/network
******** gbucs *************************
/home/ocidev/ws/oraclegbudev/src/oci-admin/environments/dev/iad/network/gbucs
******** vcns **************************
/home/ocidev/ws/oraclegbudev/src/oci-admin/environments/dev/iad/network/gbucs/vcns
terraform init -backend-config=backend-config.json -upgrade
Upgrading modules...
global in ../../../../../../modules/network/gbucs/global-data
vcn in ../../../../../../modules/network/common/vcn.v1
vcn.scripts in ../../../../../../modules/network/common/scripts
vcn-clsvc1 in ../../../../../../modules/network/common/vcn.v2
vcn-clsvc1.scripts in ../../../../../../modules/network/common/scripts
vcn-clsvc2 in ../../../../../../modules/network/common/vcn.v2
vcn-clsvc2.scripts in ../../../../../../modules/network/common/scripts
vcn-clsvc3 in ../../../../../../modules/network/common/vcn.v2
vcn-clsvc3.scripts in ../../../../../../modules/network/common/scripts
vcn-shsvc in ../../../../../../modules/network/common/vcn.v2
vcn-shsvc.scripts in ../../../../../../modules/network/common/scripts
Initializing the backend...
Initializing provider plugins...
Checking for available provider plugins...
Provider "pe" not available for installation.
A provider named "pe" could not be found in the Terraform Registry.
This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.
In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
terraform.d/plugins/linux_amd64
Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".
Downloading plugin for provider "template" (hashicorp/template) 2.2.0...
Downloading plugin for provider "null" (hashicorp/null) 3.1.1...
Error: no provider exists with the given name
Deleted object item [####################################] 100%
We've been using older versions of both Terraform and the azurerm provider and I'm trying to update the code for newer (for us) versions of each, in this case:
Terraform: v0.13.7
azurerm: v2.25
As part of the recoding, I'm switching to using the Terraform provider block:
terraform {
required_version = "~> 0.13"
required_providers {
azurerm = {
version = "= 2.25.0"
source = "hashicorp/azurerm"
}
}
}
provider azurerm {
skip_provider_registration = true
features {}
}
Terraform is downloading v2.25 of the provider but also the most version v2.67:
$ terraform init
Initializing the backend...
Initializing provider plugins...
- terraform.io/builtin/terraform is built in to Terraform
- Finding hashicorp/azurerm versions matching "2.25.0"...
- Finding latest version of -/azurerm...
- Installing hashicorp/azurerm v2.25.0...
- Installed hashicorp/azurerm v2.25.0 (signed by HashiCorp)
- Installing -/azurerm v2.67.0...
- Installed -/azurerm v2.67.0 (signed by HashiCorp)
So far this doesn't seem to be an issue, but I cannot understand why it's downloading multiple versions. Could it be because, in another code file which defines the backend (we use Azure storage for Terraform state), it's seeing that "azurerm" reference and treating it as a "new" one?
terraform {
backend azurerm {
container_name = "terraforminfra-v2"
key = "state/postgres.tfstate"
}
}
OK, I figured it out ... the "old" reference to the provider was still in the Terraform state, which I think is what was triggering the download of the most current version.
I assume I am using the latest version of azurerm:
provider "azurerm" {
version = "=2.34.0"
features {}
}
As soon as I add this resource to my tf script:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/policy_assignment
I get this error when I do terraform init:
>terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/custom...
- Finding hashicorp/azurerm versions matching "2.34.0"...
- Installing hashicorp/azurerm v2.34.0...
- Installed hashicorp/azurerm v2.34.0 (signed by HashiCorp)
Error: Failed to install provider
Error while installing hashicorp/custom: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/custom
Am I missing any custom terraform provider? Looking at the Terraform documentation in the link above, I expect the azurerm_policy_definition resource must be included n the azurerm
Thanks to #ChristianPearce who deserves the credit for the answer.
This is a common and potentially misleading error.
There could me many scripting issues that cause this error.
In my case my resource name had typo in it like below:
resource "azurerm_virtual_network_typo_in_type" "main" {
This could also be a problem with terraform sub-modules as discussed in https://github.com/hashicorp/terraform/issues/25602.
For community providers, every module requires a required_providers block with an entry specifying the provider source.
So basically you need to have this in all your modules and in your main tf-script (replace the custom-prov-name by you actual provider):
terraform {
required_providers {
custom-prov-name = {
source = ".../custom-prov-name"
}
}
}
I'm trying to run terraform locally but it should connect to an azure machine. We have azure agents that do exactly this. If I run it locally, it would help me to move faster.
Here is my command
terraform init -reconfigure -backend-config ~/common.tfvars
Here is the error
Initializing modules... │··················································
- module.kubernetes │··················································
- module.database │··················································
- module.trafficmanager │··················································
- module.appInsights │··················································
│··················································
Initializing the backend... │··················································
│··················································
Error configuring the backend "azurerm": resource_group_name and credentials must be provided when access_key is absent │··················································
│··················································
Please update the configuration in your Terraform files to fix this error │··················································
then run this command again.
cat ~/common.tfvars
resource_group_name = "myproject-nst-config-RG"
storage_account_name = "myprojectnstterraform"
container_name = "tfstatemyprojectact"
key = "nstproject"
What am I missing? Is what I want even possible?
Thank you!
You need to provide credentials for Terraform to connect to Azure, usually a service principal, this will include username/applicationID, password and tenant. Have a read of the MS documentation on using Terraform with Azure and you will see they set environment variables with these details.
If you are trying to use the az cli login, you'll want to make sure you are running Terraform 0.12.