Skip to content

Instantly share code, notes, and snippets.

@jnahelou
Last active November 10, 2017 10:21
Show Gist options
  • Save jnahelou/63947831a8154daf6bc3573cc27ed373 to your computer and use it in GitHub Desktop.
Save jnahelou/63947831a8154daf6bc3573cc27ed373 to your computer and use it in GitHub Desktop.
Download latest providers from Terraform repository
#!/bin/bash
while IFS= read -r provider
do
VERSION=`curl -s https://releases.hashicorp.com/${provider}/ | egrep -oh 'terraform-provider-[a-z0-9]+/[0-9\.]+' | sort | uniq | tail -n1`
FILENAME=`echo $VERSION | sed 's;/;_;g'`
echo "https://releases.hashicorp.com/${VERSION}/${FILENAME}_linux_amd64.zip"
wget -O "/usr/local/terraform/toolbox/providers/${FILENAME}_linux_amd64.zip" "https://releases.hashicorp.com/${VERSION}/${FILENAME}_linux_amd64.zip"
done < <(curl -s https://releases.hashicorp.com/ | egrep -oh 'terraform-provider-[a-z0-9]+' | sort | uniq)
find /usr/local/terraform/toolbox/providers/ -name '*.zip' -exec unzip -o -d /usr/local/terraform/toolbox/providers/ {} \;
find /usr/local/terraform/toolbox/providers/ -name '*.zip' -exec rm -f {} \;
#Use it !
#terraform init -plugin-dir=/usr/local/terraform/toolbox/providers/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment