forked from cloudposse/terraform-aws-ec2-instance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eni.tf
30 lines (25 loc) · 900 Bytes
/
eni.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
locals {
additional_ips_count = module.this.enabled && var.associate_public_ip_address && var.additional_ips_count > 0 ? var.additional_ips_count : 0
}
resource "aws_network_interface" "additional" {
count = local.additional_ips_count
subnet_id = var.subnet
security_groups = compact(
concat(
formatlist("%s", module.security_group.id),
var.security_groups
)
)
tags = module.this.tags
}
resource "aws_network_interface_attachment" "additional" {
count = local.additional_ips_count
instance_id = join("", aws_instance.default.*.id)
network_interface_id = aws_network_interface.additional[count.index].id
device_index = 1 + count.index
}
resource "aws_eip" "additional" {
count = local.additional_ips_count
vpc = true
network_interface = aws_network_interface.additional[count.index].id
}