0

To run Terraform for IBM Cloud we need to download a module: Module

Is there a way to place this module on central server which anyone who wants to run terraform calls. So anyone using it can access it rather than downloading it each time on their local machine to run terraform?

data_henrik
  • 16,724
  • 2
  • 28
  • 49
NoviceMe
  • 3,126
  • 11
  • 57
  • 117
  • 2
    Possible duplicate of [Use pre-installed Terraform plugins instead of downloading them with terraform init](https://stackoverflow.com/questions/50944395/use-pre-installed-terraform-plugins-instead-of-downloading-them-with-terraform-i) – ydaetskcoR Feb 05 '19 at 16:03

1 Answers1

0
terraform init -verify-plugins=false -plugin-dir=${SCRIPT_DIR}/plugins

#!/usr/bin/env bash

os=$([[ $(uname) == "Darwin" ]] && echo "darwin" || echo "linux")

plugins=$(echo -e "
  terraform-provider-aws/1.51.0/terraform-provider-aws_1.51.0_${os}_amd64.zip
  terraform-provider-archive/1.1.0/terraform-provider-archive_1.1.0_${os}_amd64.zip
  terraform-provider-external/1.0.0/terraform-provider-external_1.0.0_${os}_amd64.zip
  terraform-provider-local/1.1.0/terraform-provider-local_1.1.0_${os}_amd64.zip
  terraform-provider-null/1.0.0/terraform-provider-null_1.0.0_${os}_amd64.zip
  terraform-provider-random/2.0.0/terraform-provider-random_2.0.0_${os}_amd64.zip
  terraform-provider-template/1.0.0/terraform-provider-template_1.0.0_${os}_amd64.zip
  terraform-provider-terraform/1.0.2/terraform-provider-terraform_1.0.2_${os}_amd64.zip
  terraform-provider-tls/1.2.0/terraform-provider-tls_1.2.0_${os}_amd64.zip
  " | xargs )

for plugin in `echo $plugins`; do
  name=$(echo $plugin | cut -d'/' -f3 | cut -d'_' -f1)
  version=$(echo "$plugin" | cut -d'/' -f3 | cut -d'_' -f2)
  plug="${name}_v${version}_x4"

  if [ ! -f "$SCRIPT_DIR/plugins/$plug" ]; then
    wget -q $SCRIPT_DIR/plugins https://releases.hashicorp.com/$plugin -O plugin.zip
    unzip -q ./plugin.zip -d $SCRIPT_DIR/plugins
    rm -rf ./plugin.zip
  fi
done
victor m
  • 2,012
  • 2
  • 14
  • 23