FIX: Terraform installation 29/33429/2
authorpmikus <pmikus@cisco.com>
Mon, 9 Aug 2021 14:54:03 +0000 (14:54 +0000)
committerPeter Mikus <pmikus@cisco.com>
Mon, 9 Aug 2021 14:55:08 +0000 (14:55 +0000)
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: I2963520237c0bcc30836df3722a945060bd438d3

resources/libraries/bash/function/terraform.sh

index 929cdd8..c076f52 100644 (file)
@@ -75,8 +75,10 @@ function terraform_init () {
     set -exuo pipefail
 
     if ! installed terraform; then
-        repo="deb [arch=amd64] https://apt.releases.hashicorp.com focal main"
-        echo "${repo}" >> "/etc/apt/sources.list" || die "Failed to add repo!"
+        curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
+        os="$(lsb_release -cs)" || die "Failed to get OS release!"
+        repo="deb [arch=amd64] https://apt.releases.hashicorp.com ${os} main"
+        sudo apt-add-repository "${repo}" || die "Failed to add repo!"
         apt update -y
         apt install -y terraform
         #die "Please install terraform!"