ARTIFACTORY: Terraform modules and providers cannot be installed

Elina Floim
2023-01-25 08:24

Hashicorp’s recent change of CDN Providers had led to a change in the requests for modules and providers. As part of this change, attempts to install these from will result in “not found” errors. More information can be found here.
For example, this is an error returned from the terraform while running the terraform init command against the terraform-aws-modules/vpc/aws module:
 $ terraform init
Initializing modules...

│ Error: Module not found

│ Module "vpc" (from cannot be found in the module registry at <host>.

Due to the change, HEAD requests against the registry will return a 405 response and will fail the request. Below are examples of two HEAD requests that will return a 405 response, one when requesting a module and the other while requesting a provider:2023-01-23T10:30:59.254Z|1861691a0ccec459|test-terraform-remote||HEAD||405|0|58|131

The artifactory-request.log will log a 404 response. For example:2023-01-23T10:30:59.271Z|1861691a0ccec459|<IP>|new-admin|GET|/api/terraform/v1/modules/test-terraform__terraform-aws-modules/vpc/aws/versions|404|-1|0|188|Terraform/1.1.9
The suggested fix for this behavior is to bypass the HEAD requests in this repository by enabling the Bypass HEAD Requests checkbox. When checked, Artifactory will bypass the HEAD request and cache the artifact directly using a GET request. After the change, running terraform init should result in a successful resolution and the requests should return a 200 response:2023-01-23T10:29:47.593Z|ac9a221d8444130c|test-terraform-remote||GET||200|0|0|244