anasinnyk / terraform-provider-onepassword

Terraform provider for 1Password
GNU Lesser General Public License v3.0
128 stars 38 forks source link

Failed to instantiate provider #35

Closed Angry-Potato closed 4 years ago

Angry-Potato commented 4 years ago

Hi, thanks for the provider, it's going to (hopefully) solve an important part of automation for me!

I've installed the provider as terraform requires but I get a "failed to instantiate provider" error when terraform reaches the onepassword provider block:

...
[INFO]  plugin: configuring client automatic mTLS
[DEBUG] plugin: starting plugin: path=/root/.terraform.d/plugins/linux_amd64/terraform-provider-onepassword_v0.6.2 args=[/root/.terraform.d/plugins/linux_amd64/terraform-provider-onepassword_v0.6.2]
Error: Failed to instantiate provider "onepassword" to obtain schema: fork/exec /root/.terraform.d/plugins/linux_amd64/terraform-provider-onepassword_v0.6.2: exec format error

I'm running the terraform commands in a container based on the hashicorp/terraform:light image.

Are there some undocumented requirements for this provider, or have I missed the documentation?

Angry-Potato commented 4 years ago

when trying to execute the plugin binary directly a syntax error is generated:

/go # /root/.terraform.d/plugins/linux_amd64/terraform-provider-onepassword_v0.6
.2
/root/.terraform.d/plugins/linux_amd64/terraform-provider-onepassword_v0.6.2: line 1: syntax error: unexpected ")"

Inspecting line one of the binary:

/go # head /root/.terraform.d/plugins/linux_amd64/terraform-provider-onepassword
_v0.6.2
z�Z�-)P�@���#  (EJ���&|���^/Qt�S߸F�y��

Is this an issue with your build process, perhaps?

Angry-Potato commented 4 years ago

my fault entirely, failed to realise it's an archive rather than a binary, doh!

For any future humans bumping into this, my install script for this provider now looks like:

apk --update add curl jq
export TERRAFORM_1PASSWORD_LATEST=`curl -Ls https://api.github.com/repos/anasinnyk/terraform-provider-1password/releases/latest`
export TERRAFORM_1PASSWORD_VERSION=`echo ${TERRAFORM_1PASSWORD_LATEST} | jq -r ".tag_name"`
echo ${TERRAFORM_1PASSWORD_LATEST} | jq -r ".assets[] | select(.browser_download_url | contains(\"$(uname -s | tr A-Z a-z)\")) | select(.browser_download_url | contains(\"amd64\")) | .browser_download_url" | xargs -n 1 curl -L | tar xz -C /root/.terraform.d/plugins/linux_amd64
chmod -R a+x /root/.terraform.d/plugins/linux_amd64/*