本文介绍配置 Terraform 的操作步骤。
使用 Terraform 管理云数据库 veDB MySQL 版的云资源前,您需要先获取 AK/SK。更多关于如何获取 AK/SK 的信息,请参见访问密钥。
在任意目录下创建一个文本文件,命名为 main.tf
。
编辑 main.tf
文件,添加以下内容,设置 Provider 信息。
terraform { required_providers { volcengine = {source = "volcengine/volcengine" version = "0.0.155" } } } provider "volcengine" { access_key = "Your Access Key" secret_key = "Your Secret Key" region = "cn-beijing" }
Provider 中各字段的说明如下:
进入 main.tf
所在目录,在终端执行 terraform init
进行 terraform 的初始化。有如下响应表示配置成功。
$ terraform init Initializing the backend... Initializing provider plugins... - Reusing previous version of volcengine/volcengine from the dependency lock file - Using previously-installed volcengine/volcengine v0.0.67 Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.