Terraform使用本地编译(In-house)的Providers

简介: ## Terraform Provider的全网标识符Terraform的Provider在全网的的标识符由三部分组成,分别为`hostname`,`namespace`和`type`组成,即`//`。`hostname`是指分发、下载Provider的域名,默认为`registry.terraform.io`。`namespace`是指提供、开发Provider的组织的命名空间,默认为`has

Terraform Provider的全网标识符

Terraform的Provider在全网的的标识符由三部分组成,分别为hostnamenamespacetype组成,即<hostname>/<namespace>/<type>hostname是指分发、下载Provider的域名,默认为registry.terraform.ionamespace是指提供、开发Provider的组织的命名空间,默认为hashicorptype是指Provider的具体类型。

例如有以下Terraform模板:

terraform {
    required_providers {
         alicloud = {
          source = "aliyun/alicloud"
          version = "1.126.0"
        }
    }
}

上述模板使用terraform init命令会默认去registry.terraform.io下载aliyun开发的alicloudProvider的1.126.0版本。

本地安装Terraform Provider

如果使用本地安装插件有两种方法。首先两种方法都需要将下载的Provider或者本地编译完成的Provider放置在以下文件目录层级:

XX(e.g. /usr/share/terraform/providers/)
└── <hostname>(e.g. registry.terraform.io)
    └── <namespace>(e.g. aliyun)
        └── <type>(e.g. alicloud)
            └── <version>(e.g. 1.127.0)
                └── <your OS>(e.g. linux_amd64)
                    └── <binary file>(e.g. terraform-provider-alicloud)

方法一:使用terraform init的自带参数

第一种方法,使用terraform initplugin-dir参数:

terraform init -plugin-dir=/usr/share/terraform/providers

方法二:编写配置文件

第二种方法,编写./terraformrc配置文件,该文件需要放在$HOME/目录下:

provider_installation {
  filesystem_mirror {
    path    = "/usr/share/terraform/providers"
    include = ["registry.terraform.io/*/*"]
  }
}

其中include字段是指符合该通配符全网标识符的Provider,需要去/usr/share/terraform/providers查找本地Provider。./terraformrc的编写更详细的参数可以参考官网

相关文章
|
3月前
|
API 开发工具 Python
【Azure Developer】使用 Azure Python SDK时,遇见 The resource principal named https://management.azure.com was not found in the tenant China Azure问题的解决办法
【Azure Developer】使用 Azure Python SDK时,遇见 The resource principal named https://management.azure.com was not found in the tenant China Azure问题的解决办法
|
3月前
|
Linux C++ Docker
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
|
3月前
|
Shell PHP Windows
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
|
6月前
target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target S
target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target S
95 0
|
C++ iOS开发
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
链接如下:【金山文档】 1-Microsoft Visual C++ Build Tools。找了好久,才找到正确的解决方案,网上一大堆升级setuptools的方法只对少数人管用。注意,虽然我的这个报错内容有点长,但是我感觉和其它的。如果网页提示登录,可以不用登录,直接下载即可。然后打开镜像ios文件(双击即可)错误是一样的解决方案。文件,打开后安装即可。
2637 1
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
运行vagrant up报错 The provider 'PROVIDER' could not be found
运行vagrant up报错 The provider 'PROVIDER' could not be found
182 0
运行vagrant up报错 The provider 'PROVIDER' could not be found
|
JavaScript
vue cli3.0创项目报错‘This may cause things to work incorrectly. Make sure to use the same version for b’
vue cli3.0创项目报错‘This may cause things to work incorrectly. Make sure to use the same version for b’
vue cli3.0创项目报错‘This may cause things to work incorrectly. Make sure to use the same version for b’
|
Go 数据中心
Terraform Alicloud provider开发之Trouble Shooting
实现OTS resource `alicloud_ots_table`的表创建编排后,完成了[Terraform Alicloud provider开发入门](https://www.atatech.org/articles/104556),发现表更新删除还有不少坑。 # Terraform provider怎么debug ``` export TF_LOG=DEBUG ``` 设置后,
149 0
|
弹性计算 Ubuntu Linux
Setting Up Load Balancers Using Terraform
In this tutorial, we will learn how to set up Bolt on Alibaba Cloud ECS using Terraform load balancers and ApsaraDB for RDS.
3657 0
Setting Up Load Balancers Using Terraform
|
对象存储
Guidelines for Function Compute Development -- OSS Trigger
Preface Terms and descriptions: Function Compute: Alibaba Cloud Function Compute is an event-driven computing service that dynamically allocates resources after you write and upload code.
1131 0