-
Notifications
You must be signed in to change notification settings - Fork 0
/
security.tf
36 lines (30 loc) · 1016 Bytes
/
security.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
31
32
33
34
35
36
resource "aws_security_group" "this" {
name = format("%s_traffic", var.instance_name)
description = format("Traffic to %s instance", var.instance_name)
vpc_id = var.vpc_id
tags = {
Name = format("%s_traffic", var.instance_name)
}
}
resource "aws_security_group_rule" "example" {
for_each = var.security_group_rules
type = each.value.type
from_port = each.value.port
to_port = each.value.port
protocol = each.value.protocol
cidr_blocks = each.value.cidr_blocks
security_group_id = aws_security_group.this.id
}
resource "aws_network_interface" "this" {
subnet_id = var.subnet_id
private_ips = [var.private_ip]
security_groups = [aws_security_group.this.id]
tags = {
Name = format("%s_network_interface", var.instance_name)
}
}
resource "aws_eip" "public_access" {
count = var.associate_public_ip_address ? 1 : 0
vpc = true
network_interface = aws_network_interface.this.id
}