arvancloud_iaas_security_group_attachment (Resource)
Manages the attachment of a security group to a network port. This association controls which traffic rules apply to the port.
Example Usage
# Create a security group
resource "arvancloud_iaas_security_group" "web" {
name = "web-security-group"
description = "Security group for web servers"
availability_zone = "ir-central1-a"
}
# Add rules to the security group
resource "arvancloud_iaas_security_group_rule" "http" {
security_group_id = arvancloud_iaas_security_group.web.id
direction = "ingress"
ether_type = "IPv4"
protocol = "tcp"
port_range_min = 80
port_range_max = 80
remote_ip_prefix = "0.0.0.0/0"
description = "Allow HTTP"
}
# Assume you have a server and need to get its port ID
# you can get the port id of the server from network attachment resource
# For this example, we'll use a hypothetical port ID
# Attach the security group to a network port
resource "arvancloud_iaas_security_group_attachment" "web_to_server" {
security_group_id = arvancloud_iaas_security_group.web.id
port_id = var.server_port_id
}
Schema
Required
port_id(String) ID of the network port to attach the security group to. Can be fetched from private network attachment and add public ip resourcessecurity_group_id(String) ID of the security group to attach.
Read-Only
code(Number) Response code from the attach operation.id(String) Unique identifier for the attachment (composite of security_group_id:port_id).message(String) Response message from the attach operation.