Hi,
The current new relic provider doesn't work with Terraform v0.13.
Terraform v0.13.2
All the New Relic resources
terraform {
required_version = ">= 0.13.2"
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = "~> 2.6.1"
}
}
}
# Configure the New Relic provider
provider "newrelic" {
account_id = var.newrelic_account_id
api_key = var.newrelic_api_key
admin_api_key = var.newrelic_admin_api_key
region = "US" # Valid regions are US and EU
}
Below is the error message while doing terraform init.
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Using previously-installed newrelic/newrelic v2.6.1
- Finding latest version of hashicorp/newrelic...
Error: Failed to install providers
Could not find required providers, but found possible alternatives:
hashicorp/newrelic -> newrelic/newrelic
If these suggestions look correct, upgrade your configuration with the
following command:
terraform 0.13upgrade module/alert_channel
Please list the steps required to reproduce the issue, for example:
terraform initHi @aswiniray, can you share your module/alert_channel configuration (sensitive info redacted)?
It looks Terraform is suggesting you run terraform 0.13upgrade module/alert_channel, but it would be good to see what your configuration looks like as well so we have a reference to what might have causes Terraform to display that helper message.
Does terraform init -upgrade help here? The state file likely references the old provider path, so just thinking that the paths need to be updated.
This is because you migrated from terraform 0.12 to 0.13 and tried to apply your configuration before running terraform 0.13upgrade first. You should be able to fix it with terraform state replace-provider -auto-approve -- hashicorp/newrelic registry.terraform.io/newrelic/newrelic.
@aswiniray Can you confirm the fix that @alexjurkiewicz posted?
@aswiniray Can you confirm the fix that @alexjurkiewicz posted?
It is not a migrated project from terraform version 0.12. It is a new project starting with terraform version 0.13.
I can't run terraform state replace-provider -auto-approve -- hashicorp/newrelic registry.terraform.io/newrelic/newrelic as there is no terraform state file as it a new project and it is failing with terraform init.
In fact it is not working with terraform init -upgrade or terraform 0.13upgrade
Even I tested with provider 2.7.1 and it is throwing the same error message.
Hi @aswiniray, can you share your
module/alert_channelconfiguration (sensitive info redacted)?It looks Terraform is suggesting you run
terraform 0.13upgrade module/alert_channel, but it would be good to see what your configuration looks like as well so we have a reference to what might have causes Terraform to display that helper message.
Hi @sanderblue . My project is very simple. Below is my module/alert_channel
resource "newrelic_alert_channel" "alert_channel" {
name = "Support-DL"
type = "email"
config {
recipients = "abc.xyz.com"
include_json_attachment = "0"
}
}
The initial example works for me.
❯ cat main.tf
terraform {
required_version = ">= 0.13.2"
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = "~> 2.6.1"
}
}
}
# Configure the New Relic provider
provider "newrelic" {}
❯ terraform init
Initializing the backend...
Initializing provider plugins...
- Finding newrelic/newrelic versions matching "~> 2.6.1"...
- Installing newrelic/newrelic v2.6.1...
- Installed newrelic/newrelic v2.6.1 (signed by a HashiCorp partner, key ID DC9FC6B1FCE47986)
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/plugins/signing.html
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.
~/tmp
❯ terraform version
Terraform v0.13.2
+ provider registry.terraform.io/newrelic/newrelic v2.6.1
I'm wondering if perhaps clearing out the previously downloaded providers to for terraform would clear this up.
@aswiniray did you also try terraform 0.13upgrade module/alert_channel? That's what fixed things for me when I gave it a try.
@aswiniray did you also try
terraform 0.13upgrade module/alert_channel? That's what fixed things for me when I gave it a try.
Yes, adding the terraform 0.13upgrade module/alert_channel is resolving the issue. But I am not sure why it is asking me to upgrade the module whereas it is a fresh project with terraform 0.13.2 version? Also I can see, it is adding a version.tf (mentioned below) when I am running the terraform 0.13upgrade module/alert_channel. I am sure there is some incompatibility with Terraform 0.13, otherwise terraform should not complain about upgrading the module!! I need to upgrade every module which doesn't make sense to me.
terraform {
required_providers {
newrelic = {
source = "newrelic/newrelic"
}
}
required_version = ">= 0.13"
}
Hi @aswiniray, unfortunately this is a Terraform implementation issue and not an issue with the provider so we're closing it. We've been able to use Terraform version 0.13 with the provider without any problems.
You shouldn't have to update any modules if their configuration meets the requirements for Terraform 0.13.x. Terraform has a fairly thorough guide regarding module composition that might help. Terraforms provider requirements are also quite thorough.
I might also suggest starting with a single main.tf without any modules and add things one piece at a time to that file and rerunning terraform init to see what happens as you move forward.
Most helpful comment
This is because you migrated from terraform 0.12 to 0.13 and tried to apply your configuration before running
terraform 0.13upgradefirst. You should be able to fix it withterraform state replace-provider -auto-approve -- hashicorp/newrelic registry.terraform.io/newrelic/newrelic.