-
Notifications
You must be signed in to change notification settings - Fork 7
/
vpc_and_subnets.tf
56 lines (45 loc) · 1.14 KB
/
vpc_and_subnets.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
data "aws_vpc" "this" {
count = var.redis_enabled || var.rds_enabled ? 1 : 0
tags = var.vpc_tag_filter
}
data "aws_subnets" "redis" {
count = var.redis_enabled ? 1 : 0
filter {
name = "vpc-id"
values = [data.aws_vpc.this[0].id]
}
dynamic "filter" {
for_each = length(var.redis_subnet_cidr_block_filter) > 0 ? [1] : []
content {
name = "cidr-block"
values = var.redis_subnet_cidr_block_filter
}
}
tags = var.redis_subnet_tag_filter
}
data "aws_subnets" "rds" {
count = var.rds_enabled ? 1 : 0
filter {
name = "vpc-id"
values = [data.aws_vpc.this[0].id]
}
dynamic "filter" {
for_each = length(var.rds_subnet_cidr_block_filter) > 0 ? [1] : []
content {
name = "cidr-block"
values = var.rds_subnet_cidr_block_filter
}
}
tags = var.rds_subnet_tag_filter
}
data "aws_security_groups" "for_rds" {
count = var.rds_enabled && length(var.additional_sg_names_for_rds) >= 1 ? 1 : 0
filter {
name = "vpc-id"
values = [data.aws_vpc.this[0].id]
}
filter {
name = "group-name"
values = [for sg in var.additional_sg_names_for_rds : sg]
}
}