Provides a Nlb Load Balancer Security Group Attachment resource.
For information about Nlb Load Balancer Security Group Attachment and how to use it, see What is Load Balancer Security Group Attachment.
Basic Usage
variable "name" {
default = "tf-example"
}
data "alicloud_resource_manager_resource_groups" "default" {}
data "alicloud_nlb_zones" "default" {}
resource "alicloud_vpc" "default" {
vpc_name = var.name
cidr_block = "10.4.0.0/16"
}
resource "alicloud_vswitch" "default" {
vswitch_name = var.name
cidr_block = "10.4.0.0/24"
vpc_id = alicloud_vpc.default.id
zone_id = data.alicloud_nlb_zones.default.zones.0.id
}
resource "alicloud_vswitch" "default1" {
vswitch_name = var.name
cidr_block = "10.4.1.0/24"
vpc_id = alicloud_vpc.default.id
zone_id = data.alicloud_nlb_zones.default.zones.1.id
}
resource "alicloud_security_group" "default" {
name = var.name
vpc_id = alicloud_vpc.default.id
}
resource "alicloud_nlb_load_balancer" "default" {
load_balancer_name = var.name
resource_group_id = data.alicloud_resource_manager_resource_groups.default.ids.0
load_balancer_type = "Network"
address_type = "Internet"
address_ip_version = "Ipv4"
vpc_id = alicloud_vpc.default.id
tags = {
Created = "TF",
For = "example",
}
zone_mappings {
vswitch_id = alicloud_vswitch.default.id
zone_id = data.alicloud_nlb_zones.default.zones.0.id
}
zone_mappings {
vswitch_id = alicloud_vswitch.default1.id
zone_id = data.alicloud_nlb_zones.default.zones.1.id
}
}
resource "alicloud_nlb_load_balancer_security_group_attachment" "default" {
security_group_id = alicloud_security_group.default.id
load_balancer_id = alicloud_nlb_load_balancer.default.id
}
The following arguments are supported:
dry_run
- (Optional) Whether to PreCheck this request only. Value:
load_balancer_id
- (Required, ForceNew) The ID of the network-based server load balancer instance to be bound to the security group.security_group_id
- (Required, ForceNew, Computed) The ID of the security group.The following attributes are exported:
id
- The ID of the resource supplied above.The value is formulated as <load_balancer_id>:<security_group_id>
.The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 5 mins) Used when create the Load Balancer Security Group Attachment.delete
- (Defaults to 5 mins) Used when delete the Load Balancer Security Group Attachment.NLB Load Balancer Security Group Attachment can be imported using the id, e.g.
$ terraform import alicloud_nlb_load_balancer_security_group_attachment.example <load_balancer_id>:<security_group_id>