.tf后缀保存。您可以在 Terraform Provider 文档页面上查看 EdgeOne 站点资源 的参数定义。
以下为示例配置文件 tencent_teo.tf 的内容:terraform {required_providers {tencentcloud = {source = "tencentcloudstack/tencentcloud"version = ">= 1.78.5"}}}provider "tencentcloud" {secret_id = "<your-secret-id>"secret_key = "<your-secret-key>"region = "ap-guangzhou"}resource "tencentcloud_teo_zone" "example" {zone_name = "example.com"plan_type = "<your-plan-type>"tags = {"createdBy" = "terraform"}}
terraform init 命令初始化配置。
此步骤中,Terraform 会自动检测配置文件中的 provider 字段,并下载最新版本的模块和插件。
若打印如下信息,则表示初始化成功。Initializing the backend...Initializing provider plugins...- Finding tencentcloudstack/tencentcloud versions matching ">= 1.78.5"...- Installing tencentcloudstack/tencentcloud v1.78.5...- Installed tencentcloudstack/tencentcloud v1.78.5 (signed by a HashiCorp partner, key ID 84F69E1C1BECF459)Partner and community providers are signed by their developers.If you'd like to know more about provider signing, you can read about it here:https://www.terraform.io/docs/cli/plugins/signing.htmlTerraform has created a lock file .terraform.lock.hcl to record the providerselections it made above. Include this file in your version control repositoryso that Terraform can guarantee to make the same selections by default whenyou run "terraform init" in the future.Terraform has been successfully initialized!
terraform plan命令预览配置,可以校验配置是否正确。PS tf-doc> terraform.exe planTerraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:+ createTerraform will perform the following actions:# tencentcloud_teo_zone.example will be created+ resource "tencentcloud_teo_zone" "example" {+ area = (known after apply)+ cname_speed_up = (known after apply)+ cname_status = (known after apply)+ created_on = (known after apply)+ id = (known after apply)+ modified_on = (known after apply)+ name_servers = (known after apply)+ original_name_servers = (known after apply)+ paused = (known after apply)+ plan_type = "ent"+ resources = (known after apply)+ status = (known after apply)+ tags = {+ "createdBy" = "terraform"}+ type = (known after apply)+ vanity_name_servers_ips = (known after apply)+ zone_id = (known after apply)+ zone_name = "example.com"}Plan: 1 to add, 0 to change, 0 to destroy.───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
terraform apply添加 EdgeOne 站点。
执行 apply 命令后 Terraform 会让您再次确认将要执行的动作。在确认无误后输入yes二次确认,然后等待命令执行完成。PS tf-doc> terraform applyTerraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:+ createTerraform will perform the following actions:# tencentcloud_teo_zone.example will be created+ resource "tencentcloud_teo_zone" "example" {+ area = (known after apply)+ cname_speed_up = (known after apply)+ cname_status = (known after apply)+ created_on = (known after apply)+ id = (known after apply)+ modified_on = (known after apply)+ name_servers = (known after apply)+ original_name_servers = (known after apply)+ paused = (known after apply)+ plan_type = "ent"+ resources = (known after apply)+ status = (known after apply)+ tags = {+ "createdBy" = "terraform"}+ type = (known after apply)+ vanity_name_servers_ips = (known after apply)+ zone_id = (known after apply)+ zone_name = "example.com"}Plan: 1 to add, 0 to change, 0 to destroy.Do you want to perform these actions?Terraform will perform the actions described above.Only 'yes' will be accepted to approve.Enter a value: yestencentcloud_teo_zone.example: Creating...tencentcloud_teo_zone.example: Creation complete after 6s [id=zone-2ag9gej58j36]Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
terraform refresh刷新资源状态,然后执行terraform show查看站点是否已经生效。
以 NS 方式接入站点,生效后status字段的值应为active,以 CNAME 方式接入的站点,生效后cname_status字段的值应为finished。PS tf-doc> terraform refreshtencentcloud_teo_zone.example: Refreshing state... [id=zone-2ag9gej58j36]PS tf-doc> terraform show# tencentcloud_teo_zone.example:resource "tencentcloud_teo_zone" "example" {area = "overseas"cname_speed_up = "enabled"cname_status = "pending"...original_name_servers = []paused = falseplan_type = "ent"status = "active"tags = {"createdBy" = "terraform"}type = "full"vanity_name_servers_ips = []zone_id = "zone-2ag9gej58j36"zone_name = "example.com"}
文档反馈