provider.tf file in the user directory with the following content. Replace my-secret-id and my-secret-key with your SecretId and SecretKey, respectively.provider "tencentcloud" {secret_id = "my-secret-id"secret_key = "my-secret-key"}
YOUR_SECRET_ID and YOUR_SECRET_KEY with your SecretId and SecretKey, respectively.export TENCENTCLOUD_SECRET_ID=YOUR_SECRET_IDexport TENCENTCLOUD_SECRET_KEY=YOUR_SECRET_KEY
provider "tencentcloud" {region = "your_region"secret_id = "your_secret_id"secret_key = "your_secret_key"}
#Specifying Provider Configuration Informationterraform { required_providers { tencentcloud = { source = "tencentcloudstack/tencentcloud" } } }#Creating a Prometheus Instanceresource "tencentcloud_monitor_tmp_instance" "foo" {instance_name = "tf-tmp-instance-sjtest"vpc_id = "vpc-0n42dxzs"subnet_id = "subnet-es8rv1kx"data_retention_time = 30zone = "ap-guangzhou-3"tags = {"createdBy" = "terraform"}}#Creating a Grafana Instance(Optional)resource "tencentcloud_monitor_grafana_instance" "foo" {instance_name = "tf-grfana-cstest"vpc_id = "vpc-0n42dxzs"subnet_ids = ["subnet-es8rv1kx"]grafana_init_password = "1234567890"enable_internet = falseis_destroy = truetags = {"createdBy" = "test"}}#Binding Grafana and Prometheus Instances (Optional)resource "tencentcloud_monitor_tmp_manage_grafana_attachment" "foo" {grafana_id = tencentcloud_monitor_grafana_instance.foo.idinstance_id = tencentcloud_monitor_tmp_instance.foo.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
tencentcloud_vpc.vpc: Refreshing state... [id=vpc-3csjp7k8]tencentcloud_monitor_tmp_instance.foo: Refreshing state... [id=prom-4wcvt7p1]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_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-guangzhou-3"}Plan: 1 to add, 0 to change, 0 to destroy.
terraform apply
tencentcloud_vpc.vpc: Refreshing state... [id=vpc-3csjp7k8]tencentcloud_monitor_tmp_instance.foo: Refreshing state... [id=prom-4wcvt7p1]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_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-guangzhou-3"}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:
tencentcloud_monitor_tmp_instance.foo: Creating...tencentcloud_monitor_tmp_instance.foo: Still creating... [10s elapsed]tencentcloud_monitor_tmp_instance.foo: Creation complete after 12s [id=prom-8dyb6iny]Apply complete! Resources: 1 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:# tencentcloud_monitor_tmp_instance.foo will be destroyed- resource "tencentcloud_monitor_tmp_instance" "foo" {- api_root_path = "http://10.0.0.34:9090/api/v1" -> null- data_retention_time = 30 -> null- id = "prom-8dyb6iny" -> null- instance_name = "tf-tmp-instance-sjtest" -> null- ipv4_address = "10.0.0.34" -> null- proxy_address = "10.0.0.34:9090" -> null- remote_write = "http://10.0.0.34:9090/api/v1/prom/write" -> null- subnet_id = "subnet-es8rv1kx" -> null- tags = {- "createdBy" = "terraform"} -> null- vpc_id = "vpc-0n42dxzs" -> null- zone = "ap-guangzhou-3" -> null}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. is displayed, the instance has been successfully deleted.Feedback