terraform-provider-datadog: Terraform is not able to find the desired provider for datadog. Could not retrieve the list of available versions for provider hashicorp/datadog: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/datadog

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see https://www.terraform.io/community.html.

Terraform Version - 0.14.0 & datadog version is 3.10.0

Affected Resource(s)

Please list the resources as a list, for example:

  • datadog_synthetics_test

If this issue appears to affect multiple resources, it may be an issue with Terraform’s core, so please mention this.

Terraform Configuration Files

resource “datadog_synthetics_test” “test_api” { type = “api” subtype = “http” request_definition { method = “GET” url = “https://www.example.org” } request_headers = { Content-Type = “application/json” Authentication = “Token: 1234566789” } assertion { type = “statusCode” operator = “is” target = “200” } locations = [“aws:eu-central-1”] options_list { tick_every = 900

retry {
  count    = 2
  interval = 300
}

monitor_options {
  renotify_interval = 100
}

} name = “An API test on example.org” message = “Notify @pagerduty” tags = [“foo:bar”, “foo”, “env:test”]

status = “live” }

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

Debug Output

Please provide a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened?

Actual Behavior

What actually happened?

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform init

Important Factoids

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 28 (10 by maintainers)

Most upvoted comments

I also have this problem. Had datadog provider specified in the root module: terraform { required_providers { datadog = { source = "DataDog/datadog" } aws = { source = "hashicorp/aws" } } } Was working ok, then decided to split some of the datadog resources out into a module at which point tf init threw out the above error. I worked around this by declaring the provider in the child module. According to the documentation the declaration in the root module should be inherited implicitly by the child. https://www.terraform.io/language/modules/develop/providers I’m not sure why it’s necessary to declare it again.

For me, the solution was simple but not obvious.

At first, the initialisation fails, but it’s a physical configuration problem in your terraform code. In my case, commenting out the whole datadog module section and defining an empty one confirmed it’s an issue with the code itself.

What I did wrong: I loaded the datadog resources inside my “local datadog” module. Then used this local module within the project. I forgot to add the “terraform provider” section inside the local module. I did it just on the project root directory.

Adding the provider section to my module sorted out the issue.

The provider needs to be defined inside your local source.

It’s a configuration problem, generally it happens when you have several modules.

I just went through this annoying quirk with the interaction between terraform and terragrunt for the required_providers block specifically in the terraform {} block.

Here’s what I came up with:

In the root, I have terragrunt generate a required_providers_override.tf file with the following content:

    terraform {    
      required_providers {    
        datadog = {    
          source  = "DataDog/datadog"    
        }    
      }    
    }

Note: The name of this file is important. Files named *_override.tf are processed and merged last when terraform is invoked. See:

Then, in each module I have a terraform.tf file written that also declares a required_providers.tf block:

terraform {    
  required_providers {    
    datadog = {    
      source = "DataDog/datadog"    
    }    
  }
}

Here’s the final directory structure:

$ tree
./
├── global/
│   └── logs/
│       └── indexes/
│           └── terragrunt.hcl
├── modules/
│   ├── logs_index/
│   │   ├── main.tf
│   │   ├── output.tf
│   │   ├── terraform.tf
│       └── vars.tf
└── terragrunt.hcl

What this looks like to terraform:

$ tree

.terragrunt-cache/
└── pvN4MZH0iKL7jeedjcEmma-ZWZg/
    └── VgLK7GJVCSJlfH7SIMYw93xZvNo/
        ├── logs_index/
        │   ├── main.tf
        │   ├── output.tf
        │   ├── terraform.tf
        │   └── vars.tf
        └── logs_indexes_config/
            ├── main.tf
            ├── terraform.tf
            ├── terragrunt.hcl
            ├── terragrunt_providers.tf
            ├── terragrunt_required_providers_override.tf  # <-- This overrides the required_providers {} block in `terraform.tf`
            ├── terragrunt_state.tf
            └── vars.tf

Now both terraform and terragrunt are happy.

Terraform can see in each module a terraform.tf with contents terraform { required_providers { ... } } where the DataDog/datadog provider path is properly written. Terragrunt is happy because it generates the terragrunt_required_providers_override.tf file which is used (and processed/merged last) when terragrunt plan and other commands are invoked.

I seriously hope this helps someone else.