Review default security group use by Tencent Cloud CVM

Use security groups that permit only the traffic a workload needs.

Description

Review the rules and order of the security groups attached to a CVM instance. Sharing one group across services can permit ports that only some services need.

Potential impact

Changing a shared rule can also interrupt connections to other instances using the group.

Remediation

Give workloads with different access requirements separate groups and define the required ingress and egress. List the group IDs in the intended order in orderly_security_groups and test service and management connectivity.

Examples

The excerpts use the older security_groups field to change the association from default to web. The name and description of web-sg do not define its permissions. Supply the omitted rules and instance settings.

Before

hcl
resource "tencentcloud_instance" "example" {
  instance_name = "cvm-postpaid"

  security_groups = [
    tencentcloud_security_group.default.id
  ]
}

After

hcl
resource "tencentcloud_security_group" "web" {
  name        = "web-sg"
  description = "web instance security group"
}

resource "tencentcloud_instance" "example" {
  instance_name = "cvm-postpaid"

  security_groups = [
    tencentcloud_security_group.web.id
  ]
}

References