Description
Alibaba Cloud flow logs record traffic metadata for a VPC, vSwitch or network interface.
Potential impact
Choosing the wrong scope can leave gaps when you trace failed connections or unusual traffic.
Remediation
Select the target and traffic with resource_id, resource_type and traffic_type. Activate the log, point it to a Simple Log Service project and Logstore, then check for matching traffic and set retention.
Examples
The example adds an Active log to the VPC. traffic_type = "All" records both accepted and rejected traffic. Packet contents are outside its scope.
Before
hcl
resource "alicloud_vpc" "main" {
cidr_block = "192.168.0.0/24"
name = var.name
}
After
hcl
resource "alicloud_vpc" "main" {
cidr_block = "192.168.0.0/24"
name = var.name
}
resource "alicloud_vpc_flow_log" "default" {
resource_id = alicloud_vpc.main.id
resource_type = "VPC"
traffic_type = "All"
log_store_name = var.log_store_name
project_name = var.project_name
flow_log_name = var.name
status = "Active"
}