Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when using local providers due to incomplete lock file #3568

Open
1 task done
acastlemilk opened this issue Mar 25, 2024 · 0 comments
Open
1 task done

error when using local providers due to incomplete lock file #3568

acastlemilk opened this issue Mar 25, 2024 · 0 comments
Labels
bug Something isn't working new Un-triaged issue

Comments

@acastlemilk
Copy link

acastlemilk commented Mar 25, 2024

Expected Behavior

with a terraform.rc as follows:

plugin_cache_may_break_dependency_lock_file = true
provider_installation {
  filesystem_mirror {
    path = "<insert-some-local-path>/providers/"
    include = ["registry.terraform.io/atlassian/tome"]
  }

  direct {
      exclude = ["registry.terraform.io/atlassian/tome"]
    }
}

on cdktf deploy ... it should create the lock file during terraform init and proceed with deployment of resources.

Actual Behavior

It errors with:

Initializing the backend...
Initializing provider plugins...
Finding atlassian/tome versions matching "1.4.7"...
Using atlassian/tome v1.4.7 from the shared cache directory
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.
  ╷
                            │ Warning: Incomplete lock file information for providers
                            │ 
                            │ Due to your customized provider installation methods, Terraform was forced to
                            │ calculate lock file checksums locally for the following providers:
                            │   - atlassian/tome
                            │ 
                            │ The current .terraform.lock.hcl file only includes checksums for
                            │ darwin_arm64, so Terraform running on another platform will fail to install
                            │ these providers.
                            │ 
                            │ To calculate additional checksums for another platform, run:
                            │   terraform providers lock -platform=linux_amd64
                            │ (where linux_amd64 is the platform to generate)
                            ╵
                            
                            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.


0 Stacks deploying     0 Stacks done     1 Stack waiting
[2024-03-26T10:12:32.808] [ERROR] default - ╷
│ Error: Could not retrieve providers for locking
│ 
│ Terraform failed to fetch the requested providers for linux_amd64 in order
│ to calculate their checksums: some providers could not be installed:
│ - registry.terraform.io/atlassian/tome: provider registry
│ registry.terraform.io does not have a provider named
│ registry.terraform.io/atlassian/tome.
micros-server-capabilities  ╷
                            │ Error: Could not retrieve providers for locking
                            │ 
                            │ Terraform failed to fetch the requested providers for linux_amd64 in order
                            │ to calculate their checksums: some providers could not be installed:
                            │ - registry.terraform.io/atlassian/tome: provider registry
                            │ registry.terraform.io does not have a provider named
                            │ registry.terraform.io/atlassian/tome.
                            ╵
                           
0 Stacks deploying     0 Stacks done     1 Stack waiting
Error: non-zero exit code 1

Re-running cdktf deploy then works, as the lock file now exists.

Steps to Reproduce

  1. use a custom/local provider with the above setup terraform.rc
  2. create a stack which uses the provider
  3. run cdktf deploy which will fail due to incomplete lock warning
  4. re-run cdktf deploy and it will work as expected

Versions

language: java
cdktf-cli: 0.20.1
node: v21.6.0
cdktf: 0.20.4
constructs: 10.3.0
jsii: 1.96.0
terraform: 1.5.7
arch: arm64
os: darwin 23.4.0
java:
maven: [MVNVM] Using maven: 3.9.6Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)Maven home: /Users/bebsworth/.mvnvm/apache-maven-3.9.6Java version: 21.0.1, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/HomeDefault locale: en_AU, platform encoding: UTF-8OS name: "mac os x", version: "14.4", arch: "aarch64", family: "mac"
gradle: ------------------------------------------------------------Gradle 8.5------------------------------------------------------------Build time: 2023-11-29 14:08:57 UTCRevision: 28aca86a7180baa17117e0e5ba01d8ea9feca598Kotlin: 1.9.20Groovy: 3.0.17Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023JVM: 21.0.1 (Homebrew 21.0.1)OS: Mac OS X 14.4 aarch64
providers
splunk-terraform/signalfx@undefined (LOCAL)
terraform provider version: 9.1.1
atlassian/tome@undefined (LOCAL)
terraform provider version: 1.4.7

Providers

┌───────────────────────────┬──────────────────┬───────┬────────────┬──────────────┬─────────────────┐
│ Provider Name │ Provider Version │ CDKTF │ Constraint │ Package Name │ Package Version │
├───────────────────────────┼──────────────────┼───────┼────────────┼──────────────┼─────────────────┤
│ splunk-terraform/signalfx │ 9.1.1 │ │ │ │ │
├───────────────────────────┼──────────────────┼───────┼────────────┼──────────────┼─────────────────┤
│ atlassian/tome │ 1.4.7 │ │ │ │ │
└───────────────────────────┴──────────────────┴───────┴────────────┴──────────────┴─────────────────┘

Gist

No response

Possible Solutions

It seems it might be taking the lock file warning from terraform init as non-empty stderr output and exiting early. Perhaps the error handling can be improve as to allow cdktf deploy to continue even after getting the warning about the lock file

Workarounds

running cdktf deploy twice

Anything Else?

No response

References

similar issue in hashicorp/terraform#32906

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@acastlemilk acastlemilk added bug Something isn't working new Un-triaged issue labels Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Un-triaged issue
Projects
None yet
Development

No branches or pull requests

1 participant