Loading...
Loading...
### Terraform Version ```shell 1.3.1 ``` ### Terraform Configuration Files Add below to ~/.terraformrc. ``` provider_installation { direct { exclude = ["registry.terraform.io/*/*"] } network_mirror { url = "https://{artifactory-domain}/artifactory/api/terraform/{terraform-repository}/providers/" } } credentials "artifactory.com" { token = "xxxxxx" } ``` ### Debug Output ### Running ``` terraform init``` ``` 2022-10-05T14:44:58.936-0500 [INFO] Terraform version: 1.3.1 2022-10-05T14:44:58.936-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0 2022-10-05T14:44:58.937-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1 2022-10-05T14:44:58.937-0500 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 2022-10-05T14:44:58.938-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 2022-10-05T14:44:58.938-0500 [DEBUG] using github.com/zclconf/go-cty v1.11.0 2022-10-05T14:44:58.939-0500 [INFO] Go runtime version: go1.19.1 2022-10-05T14:44:58.939-0500 [INFO] CLI args: []string{"terraform", "init"} 2022-10-05T14:44:58.940-0500 [TRACE] Stdout is a terminal of width 172 2022-10-05T14:44:58.941-0500 [TRACE] Stderr is a terminal of width 172 2022-10-05T14:44:58.941-0500 [TRACE] Stdin is a terminal 2022-10-05T14:44:58.941-0500 [DEBUG] Attempting to open CLI config file: /home/mcj/.terraformrc 2022-10-05T14:44:58.942-0500 [INFO] Loading CLI configuration from /home/mcj/.terraformrc 2022-10-05T14:44:58.943-0500 [INFO] Loading CLI configuration from /home/mcj/.terraform.d/credentials.tfrc.json 2022-10-05T14:44:58.944-0500 [DEBUG] Explicit provider installation configuration is set 2022-10-05T14:44:58.945-0500 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes [registry.terraform.io/*/*] 2022-10-05T14:44:58.945-0500 [TRACE] Selected provider installation method cliconfig.ProviderInstallationNetworkMirror("https://artifactory.com/artifactory/api/terraform/terraform-repo/providers/") with includes [] and excludes [] 2022-10-05T14:44:58.946-0500 [INFO] CLI command args: []string{"init"} Initializing the backend... 2022-10-05T14:44:58.963-0500 [TRACE] Meta.Backend: built configuration for "remote" backend with hash value 2368007724 2022-10-05T14:44:58.968-0500 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory 2022-10-05T14:44:58.968-0500 [DEBUG] New state was assigned lineage "99e660d9-c9bc-f242-c2b5-f7ef31f64980" 2022-10-05T14:44:58.969-0500 [TRACE] Meta.Backend: moving from default local state only to "remote" backend 2022-10-05T14:44:58.970-0500 [DEBUG] checking for provisioner in "." 2022-10-05T14:44:59.192-0500 [DEBUG] checking for provisioner in "/usr/bin" 2022-10-05T14:44:59.193-0500 [TRACE] backend/local: state manager for workspace "default" will: - read initial snapshot from terraform.tfstate - write new snapshots to terraform.tfstate - create any backup at terraform.tfstate.backup 2022-10-05T14:44:59.194-0500 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate 2022-10-05T14:44:59.195-0500 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay 2022-10-05T14:44:59.195-0500 [TRACE] statemgr.Filesystem: read nil snapshot 2022-10-05T14:44:59.195-0500 [TRACE] Meta.Backend: ignoring local "default" workspace because its state is empty 2022-10-05T14:44:59.196-0500 [DEBUG] Service discovery for artifactory.com at https://artifactory.com/.well-known/terraform.json 2022-10-05T14:44:59.196-0500 [TRACE] HTTP client GET request to https://artifactory.com/.well-known/terraform.json 2022-10-05T14:45:00.595-0500 [DEBUG] New state was assigned lineage "01430463-442e-8cd8-d514-630beadd6bc3" 2022-10-05T14:45:00.671-0500 [TRACE] Preserving existing state lineage "01430463-442e-8cd8-d514-630beadd6bc3" Successfully configured the backend "remote"! Terraform will automatically use this backend unless the backend configuration changes. ``` ### After initialization, created new workspace and running ```terraform plan``` gives below error: ``` ╷ │ Error: Inconsistent dependency lock file │ │ The following dependency selections recorded in the lock file are inconsistent with the current configuration: │ - provider registry.terraform.io/hashicorp/aws: required by this configuration but no version is selected │ │ To make the initial dependency selections that will initialize the dependency lock file, run: │ terraform init ``` ### Expected Behavior Terraform initialization involving JFrog terraform backend repository as a backend resolves providers and modules correctly. ### Actual Behavior Terraform initialization involving JFrog terraform backend repository as a backend is not resolving providers and modules correctly. If initialized with `-backend=false`, the providers or resources are getting installed. `terraform init -backend=false` ``` 2022-10-05T15:36:40.285-0500 [INFO] Terraform version: 1.3.1 2022-10-05T15:36:40.286-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0 2022-10-05T15:36:40.286-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1 2022-10-05T15:36:40.287-0500 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 2022-10-05T15:36:40.287-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 2022-10-05T15:36:40.288-0500 [DEBUG] using github.com/zclconf/go-cty v1.11.0 2022-10-05T15:36:40.288-0500 [INFO] Go runtime version: go1.19.1 2022-10-05T15:36:40.288-0500 [INFO] CLI args: []string{"terraform", "init", "-backend=false"} 2022-10-05T15:36:40.289-0500 [TRACE] Stdout is a terminal of width 172 2022-10-05T15:36:40.289-0500 [TRACE] Stderr is a terminal of width 172 2022-10-05T15:36:40.289-0500 [TRACE] Stdin is a terminal 2022-10-05T15:36:40.290-0500 [DEBUG] Attempting to open CLI config file: /home/mcj/.terraformrc 2022-10-05T15:36:40.291-0500 [INFO] Loading CLI configuration from /home/mcj/.terraformrc 2022-10-05T15:36:40.292-0500 [INFO] Loading CLI configuration from /home/mcj/.terraform.d/credentials.tfrc.json 2022-10-05T15:36:40.293-0500 [DEBUG] Explicit provider installation configuration is set 2022-10-05T15:36:40.293-0500 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes [registry.terraform.io/*/*] 2022-10-05T15:36:40.293-0500 [TRACE] Selected provider installation method cliconfig.ProviderInstallationNetworkMirror("https://artifactory.com/artifactory/api/terraform/terraform-repo/providers/") with includes [] and excludes [] 2022-10-05T15:36:40.294-0500 [INFO] CLI command args: []string{"init", "-backend=false"} 2022-10-05T15:36:40.300-0500 [TRACE] Preserving existing state lineage "01430463-442e-8cd8-d514-630beadd6bc3" 2022-10-05T15:36:40.300-0500 [TRACE] Preserving existing state lineage "01430463-442e-8cd8-d514-630beadd6bc3" 2022-10-05T15:36:40.301-0500 [TRACE] Meta.Backend: working directory was previously initialized for "remote" backend 2022-10-05T15:36:40.301-0500 [DEBUG] Service discovery for artifactory.com at https://artifactory.com/.well-known/terraform.json 2022-10-05T15:36:40.307-0500 [TRACE] HTTP client GET request to https://artifactory.com/.well-known/terraform.json Initializing provider plugins... - Finding hashicorp/aws versions matching "~> 4.16"... 2022-10-05T15:36:41.253-0500 [DEBUG] Querying available versions of provider registry.terraform.io/hashicorp/aws at network mirror https://artifactory.com/artifactory/api/terraform/terraform-repo/providers/ 2022-10-05T15:36:41.256-0500 [DEBUG] GET https://artifactory.com/artifactory/api/terraform/terraform-repo/providers/registry.terraform.io/hashicorp/aws/index.json 2022-10-05T15:36:41.258-0500 [TRACE] HTTP client GET request to https://artifactory.com/artifactory/api/terraform/terraform-repo/providers/registry.terraform.io/hashicorp/aws/index.json 2022-10-05T15:36:41.765-0500 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers 2022-10-05T15:36:41.767-0500 [TRACE] getproviders.SearchLocalDirectory: failed to resolve symlinks for .terraform/providers: lstat .terraform/providers: no such file or directory 2022-10-05T15:36:41.768-0500 [TRACE] providercache.fillMetaCache: error while scanning directory .terraform/providers: cannot search .terraform/providers: lstat .terraform/providers: no such file or directory 2022-10-05T15:36:41.769-0500 [DEBUG] Finding package URL for registry.terraform.io/hashicorp/aws v4.33.0 on linux_amd64 via network mirror https:/ artifactory.com/artifactory/api/terraform/terraform-repo/providers/ 2022-10-05T15:36:41.770-0500 [DEBUG] GET https:/ artifactory.com/artifactory/api/terraform/terraform-repo/providers/registry.terraform.io/hashicorp/aws/4.33.0.json 2022-10-05T15:36:41.771-0500 [TRACE] HTTP client GET request to https:/ artifactory.com/artifactory/api/terraform/terraform-repo/providers/registry.terraform.io/hashicorp/aws/4.33.0.json - Installing hashicorp/aws v4.33.0... 2022-10-05T15:36:43.345-0500 [TRACE] providercache.Dir.InstallPackage: installing registry.terraform.io/hashicorp/aws v4.33.0 from https:/ artifactory.com/artifactory/api/terraform/terraform-repo/providers/terraform-provider-aws/4.33.0/terraform-provider-aws_4.33.0_linux_amd64.zip?sig=XXXXXXXX 2022-10-05T15:36:43.346-0500 [TRACE] HTTP client GET request to https:/ artifactory.com/artifactory/api/terraform/terraform-repo/providers/terraform-provider-aws/4.33.0/terraform-provider-aws_4.33.0_linux_amd64.zip?sig=XXXXXXXX 2022-10-05T15:36:50.848-0500 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers 2022-10-05T15:36:50.856-0500 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v4.33.0 for linux_amd64 at .terraform/providers/registry.terraform.io/hashicorp/aws/4.33.0/linux_amd64 2022-10-05T15:36:50.857-0500 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/4.33.0/linux_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 4.33.0 - Installed hashicorp/aws v4.33.0 (unauthenticated) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. ``` ### Steps to Reproduce 1. Add remote backend in terraform .tf files. ```hcl terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 4.16" } } required_version = ">= 1.2.0" backend "remote" { hostname = "artifactory.com" organization = "tf-backend-local" workspaces { prefix = "tf-example" } } } provider "aws" { region = "us-east-1" } ``` 2. Run `terraform init` 3. Run `terraform workspace new tf-example` 4. Run `terraform plan` ### Additional Context If artifactory network mirror and provider config is omitted, still the provider does not get resolved from open source terraform registry. ### References _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.