这是一个系列,记录了在不同的云厂商中使用Terraform的一些注意事项与常见的问题,以供参考。
认证
概述
Oracle的认证相比其他云要稍微复杂一些,需要的认证信息包括:
- 租户ID:tenancy_ocid
- 用户ID:user_ocid
- API访问需要的秘钥对的私钥
- API访问需要的秘钥对的指纹(fingerprint)
这些信息可以参考:API Key Authentication@Configuring the Provider@Oracle Cloud Infrastructure Documentation。也注意到,在Oracle Cloud的文档中,有较为完整的Terraform文档,其目录为:Developer Resouces -> DevOps Tools and Plug-ins -> Terraform Provider。
在Terraform中的认证
在Terraform中认证,有两种常见的形式,一种是在provider提供完整的信息,如下:
provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
region = var.region
}
也可以在Bash中使用全局变量:
export TF_VAR_tenancy_ocid="......"
export TF_VAR_user_ocid="......"
export TF_VAR_fingerprint="......"
export TF_VAR_private_key_path="......"
(more…)