hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.57k stars 9.54k forks source link

Custom Plugins not working in Dockerfile #24561

Closed Tang8330 closed 4 years ago

Tang8330 commented 4 years ago

Terraform Version

$ tf --version
Terraform v0.12.3
+ provider.twilio v0.1.2

Debug Output

Step 7/12 : RUN make USER=root
 ---> Running in ac35b4e73eab
mkdir -p ~/.terraform.d/plugins
wget https://github.com/Preskton/terraform-provider-twilio/releases/download/0.1.2/terraform-provider-twilio_v0.1.2_linux_amd64 -O ~/.terraform.d/plugins/terraform-provider-twilio_v0.1.2
Connecting to github.com (192.30.255.112:443)
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (52.217.8.156:443)
terraform-provider-t   0% |                                |  220k  0:02:20 ETA
terraform-provider-t   6% |**                              | 2005k  0:00:29 ETA
terraform-provider-t  17% |*****                           | 5354k  0:00:14 ETA
terraform-provider-t  36% |***********                     | 11.0M  0:00:06 ETA
terraform-provider-t  69% |**********************          | 21.2M  0:00:02 ETA
terraform-provider-t  92% |*****************************   | 28.1M  0:00:00 ETA
terraform-provider-t 100% |********************************| 30.4M  0:00:00 ETA

for filename in $(ls /root/.terraform.d/plugins/); do echo $filename; done;
terraform-provider-twilio_v0.1.2
echo $(du -sh /root/.terraform.d/plugins/terraform-provider-twilio_v0.1.2)
30.4M /root/.terraform.d/plugins/terraform-provider-twilio_v0.1.2
chmod -R u+x ~/.terraform.d/plugins
Removing intermediate container ac35b4e73eab
 ---> f30ea91305b9
Step 8/12 : RUN chmod -R a+x /root/.terraform.d/plugins/*
 ---> Running in 5b4c05d64e29
Removing intermediate container 5b4c05d64e29
 ---> bb3f30372582
Step 9/12 : RUN terraform init
 ---> Running in 8477f2550ab7
Initializing modules...
- twilio_dev in environments/dev
- twilio_dev.twilio in twilio

Initializing the backend...

Initializing provider plugins...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.twilio: version = "~> 0.1"

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.
Removing intermediate container 8477f2550ab7
 ---> b28dce2bfe9d
Step 10/12 : RUN terraform plan
 ---> Running in 7cebde140f7b

Error: Failed to instantiate provider "twilio" to obtain schema: fork/exec /root/.terraform.d/plugins/terraform-provider-twilio_v0.1.2: no such file or directory

Crash Output

Expected Behavior

The file clearly exists, after doing both

ls ~/.terraform/plugins.d/*
AND
du -sh 

Actual Behavior

TF init is passing TF plan fails saying it can't find the file. But it clearly exists.

Steps to Reproduce

Additional Context

References

Tang8330 commented 4 years ago

Seems like this is a common enough bug.

https://github.com/Preskton/terraform-provider-twilio/pull/46 https://github.com/Mastercard/terraform-provider-restapi/pull/66

danieldreier commented 4 years ago

@Tang8330 can you please include or link to the Dockerfile you're using to help me reproduce this locally? Sounds like an issue other folks have had, but I need to reproduce it on my end to confirm and understand what's going on.

apparentlymart commented 4 years ago

Hi @Tang8330,

We didn't hear back from you after @danieldreier's recent comment, so I'm going to close this.

Based on what I see in the two other issues issue you mentioned, this problem seems to be with the provider build itself rather than with Terraform Core. Specifically, if a provider is built in such a way that it depends on the current system's C library, which is often glibc on a full build system, then it can fail to run under a Linux distribution that uses a different C library; some versions of Alpine Linux use uclibc and others use musl. When executing a program that is compiled against the wrong C library, the system call to execute the program returns "no such file or directory" in reference to the missing library, which Terraform is then passing on in its error message.

Terraform and its providers should be built for Linux with CGO_ENABLED=0 so that they do not depend on any particular C library, and depend only on the Linux system call interface. They can then work under any Linux distribution, including Alpine Linux. The fix you submitted to the Twilio provider is the best way to address this for other providers, to ensure that they are compatible with any system using a sufficiently new Linux kernel version, regardless of which C library is installed.

Thanks for submitting that fix to the Twilio provider! :tada:

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.