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 registry.terraform.io 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 main.tf:9) cannot be found in the module registry at <host>. ╵
Due to the change, HEAD requests against the registry.terraform.io 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|https://registry.terraform.io/v1/modules/terraform-aws-modules/vpc/aws/versions|405|0|58|131 2023-01-23T12:21:59.254Z|f67f0075f37bc6b8|test-terraform-remote||HEAD|https://registry.terraform.io/v1/providers/splunk-terraform/signalfx/versions|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|https://registry.terraform.io/v1/modules/terraform-aws-modules/vpc/aws/versions|200|0|0|244 2023-01-23T10:29:48.271Z|5279686b7bfe8eea|test-terraform-remote||GET|https://registry.terraform.io/v1/modules/terraform-aws-modules/vpc/aws/3.19.0/download|204|0|0|3