要为IBM Cloud运行Terraform,我们需要下载一个模块: Module
是否有一种方法可以将该模块放置在任何要运行Terraform调用的中央服务器上。这样,使用它的任何人都可以访问它,而不必每次都在本地计算机上运行terraform来下载它?
答案 0 :(得分: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