provider.tf
文件,输入如下内容。其中my-secret-id
和 my-secret-key
需替换为密钥 SecretId 和 SecretKey。provider "tencentcloud" {secret_id = "my-secret-id"secret_key = "my-secret-key"}
YOUR_SECRET_ID
和 YOUR_SECRET_KEY
需替换为密钥 SecretId 和 SecretKey。export TENCENTCLOUD_SECRET_ID=YOUR_SECRET_IDexport TENCENTCLOUD_SECRET_KEY=YOUR_SECRET_KEY
# 指定 provider 配置信息terraform { required_providers { tencentcloud = { source = "tencentcloudstack/tencentcloud" } } }# prometheus管理云监控集成## black-box 集成resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {instance_id = tencentcloud_monitor_tmp_instance.foo.idkind = "blackbox-exporter"content = "{\\"name\\":\\"balck-box-tf-test\\",\\"kind\\":\\"blackbox-exporter\\",\\"spec\\":{\\"instanceSpec\\":{\\"module\\":\\"http_get\\",\\"urls\\":[\\"http://baidu.com\\"]}}}"kube_type = 1cluster_id = ""}## 云监控插件集成resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterMointor" {instance_id = tencentcloud_monitor_tmp_instance.foo.idkind = "qcloud-exporter"content = "{\\"name\\":\\"tf-test-cjtest\\",\\"kind\\":\\"qcloud-exporter\\",\\"spec\\":{\\"instanceSpec\\":{\\"region\\":\\"ap-guangzhou\\",\\"delaySeconds\\":0,\\"reload_interval_minutes\\":10,\\"useRole\\":true,\\"labels\\":{}},\\"exporterSpec\\":{\\"cvm\\":true,\\"cbs\\":false,\\"lb_public\\":true,\\"lb_private\\":false,\\"tgw_set\\":false,\\"cmongo\\":false,\\"cdb\\":false,\\"redis\\":false,\\"redis_mem\\":false,\\"mariadb\\":false,\\"postgres\\":false,\\"tdmysql\\":false,\\"cynosdb_mysql\\":false,\\"sqlserver\\":false,\\"nat_gateway\\":false,\\"ckafka\\":false,\\"rocketmq\\":false,\\"tdmq\\":false,\\"lb\\":false,\\"vpngw\\":false,\\"vpnx\\":false,\\"cdn\\":false,\\"ov_cdn\\":false,\\"cos\\":false,\\"dc\\":false,\\"dcx\\":false,\\"dcg\\":false,\\"lighthouse\\":false,\\"nacos\\":false,\\"zookeeper\\":false,\\"ces\\":false,\\"dts\\":false,\\"vbc\\":false,\\"gaap\\":false,\\"waf\\":false,\\"cfs\\":false,\\"bwp\\":false,\\"scf_v2\\":false,\\"vod\\":false,\\"cls\\":false,\\"apigateway\\":false,\\"self\\":false},\\"scrapeSpec\\":{\\"relabelConfigs\\":\\"metricRelabelings:\\\\n- action: labeldrop\\\\n regex: tmp_test_label\\\\n\\"}}}"kube_type = 1cluster_id = ""}
terraform init
Initializing the backend...Initializing provider plugins...- Reusing previous version of tencentcloudstack/tencentcloud from the dependency lock file- Using previously-installed tencentcloudstack/tencentcloud v1.81.32Terraform has been successfully initialized!You may now begin working with Terraform. Try running "terraform plan" to seeany changes that are required for your infrastructure. All Terraform commandsshould 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, othercommands will detect it and remind you to do so if necessary.
terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with thefollowing symbols:+ createTerraform will perform the following actions:# tencentcloud_monitor_tmp_exporter_integration.tmpExporterIntegration will be created+ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {+ content = jsonencode(XXX...)+ id = (known after apply)+ instance_id = (known after apply)+ kind = "blackbox-exporter"+ kube_type = 1}# tencentcloud_monitor_tmp_exporter_integration.tmpExporterMointor will be created+ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterMointor" {+ content = jsonencode(XXX...)+ id = (known after apply)+ instance_id = (known after apply)+ kind = "qcloud-exporter"+ kube_type = 1}# tencentcloud_monitor_tmp_instance.foo will be created+ resource "tencentcloud_monitor_tmp_instance" "foo" {+ api_root_path = (known after apply)+ data_retention_time = 30+ id = (known after apply)+ instance_name = "tf-tmp-instance-sjtest"+ ipv4_address = (known after apply)+ proxy_address = (known after apply)+ remote_write = (known after apply)+ subnet_id = "subnet-es8rv1kx"+ tags = {+ "createdBy" = "terraform"}+ vpc_id = "vpc-0n42dxzs"+ zone = "ap-mumbai-1"}Plan: 3 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 ifyou run "terraform apply" now.
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with thefollowing symbols:+ createTerraform will perform the following actions:XXX...Plan: 3 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_monitor_tmp_instance.foo: Creating...tencentcloud_monitor_tmp_instance.foo: Still creating... [10s elapsed]。。。Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
terraform destroy
tencentcloud_monitor_tmp_instance.foo: Refreshing state... [id=prom-8dyb6iny]Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with thefollowing symbols:- destroyTerraform will perform the following actions:XXX...Plan: 0 to add, 0 to change, 1 to destroy.Do you really want to destroy all resources?Terraform will destroy all your managed infrastructure, as shown above.There is no undo. Only 'yes' will be accepted to confirm.Enter a value: yestencentcloud_monitor_tmp_instance.foo: Destroying... [id=prom-8dyb6iny]tencentcloud_monitor_tmp_instance.foo: Destruction complete after 6sDestroy complete! Resources: 1 destroyed.
Destroy complete! Resources: 1 destroyed.
表示您已删除该实例。
本页内容是否解决了您的问题?