Skip to content

Commit cbb125c

Browse files
authored
Merge pull request #7 from bitops-plugins/enh/use-latest-terraform
Install the latest Terraform version
2 parents b189c2d + 91632e2 commit cbb125c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

install.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ echo ""
1010
apk info
1111

1212
# export TERRAFORM_VERSIONS=$(cat build.config.yaml | shyaml get-values terraform.versions)
13-
TERRAFORM_VERSION=1.2.2
13+
LATEST_RELEASE=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest | jq --raw-output '.tag_name' | cut -c 2-)
14+
TERRAFORM_VERSION=${LATEST_RELEASE}
1415
echo "USING TERRAFORM VERSION: [$TERRAFORM_VERSION]"
1516

16-
1717
mkdir -p /opt/download
1818
cd /opt/download
1919

2020
echo "CD - DOWNLOAD FOLDER"
2121

22-
if command -v terraform &> /dev/null
23-
then
24-
# Terraform already installed
22+
# Terraform already installed
23+
if command -v terraform &> /dev/null; then
2524
exit
2625
fi
2726

28-
2927
echo "INSTALLING TERRAFORM"
3028

3129
TERRAFORM_DOWNLOAD_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
@@ -35,4 +33,5 @@ mv terraform /usr/local/bin/terraform-${TERRAFORM_VERSION}
3533
ln -s /usr/local/bin/terraform-${TERRAFORM_VERSION} /usr/local/bin/terraform
3634
chmod +x /usr/local/bin/terraform-${TERRAFORM_VERSION}
3735

38-
36+
# Verify the Terraform installation
37+
terraform version

0 commit comments

Comments
 (0)