Description
A public IP can give a CVM instance an internet path. Routes, security groups, the host firewall, and service authentication determine effective access.
Potential impact
Permissive rules can expose internal services or management ports to unwanted connections and sign-in attempts.
Remediation
If direct public access is unnecessary, prepare a load balancer for public services, a VPN or jump host for administration, and any required outbound path. Set allocate_public_ip = false. Review the Terraform plan for replacement or downtime and restrict firewalls and security groups to required traffic.
Examples
Set var.instance_type to a type supported in the chosen zone. POSTPAID_BY_HOUR selects the billing mode. Supply your own image, VPC, and subnet IDs.
Before
resource "tencentcloud_instance" "app_server" {
instance_name = "cvm-postpaid"
availability_zone = "ap-guangzhou-7"
image_id = "img-9qrfy1xt"
instance_type = var.instance_type
instance_charge_type = "POSTPAID_BY_HOUR"
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = 50
vpc_id = "vpc-axrsmmrv"
subnet_id = "subnet-861wd75e"
internet_max_bandwidth_out = 100
allocate_public_ip = true
}
After
resource "tencentcloud_instance" "app_server" {
instance_name = "cvm-postpaid"
availability_zone = "ap-guangzhou-7"
image_id = "img-9qrfy1xt"
instance_type = var.instance_type
instance_charge_type = "POSTPAID_BY_HOUR"
system_disk_type = "CLOUD_PREMIUM"
system_disk_size = 50
vpc_id = "vpc-axrsmmrv"
subnet_id = "subnet-861wd75e"
allocate_public_ip = false
}