-
Notifications
You must be signed in to change notification settings - Fork 4
/
data.tf
48 lines (38 loc) · 931 Bytes
/
data.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
data "aws_availability_zones" "available" {
state = "available"
}
data "aws_caller_identity" "current" {}
data "aws_partition" "current" {}
data "aws_region" "current" {}
data "aws_vpc" "preconfigured" {
count = local.create_vpc ? 0 : 1
id = var.vpcId
}
data "aws_subnets" "private_subnets" {
count = local.create_vpc ? 0 : 1
filter {
name = "vpc-id"
values = [var.vpcId]
}
tags = {
purpose = "private"
}
}
data "aws_subnet" "private_subnet" {
for_each = local.create_vpc ? toset([]) : toset(data.aws_subnets.private_subnets[0].ids)
id = each.value
}
data "aws_subnets" "public_subnets" {
count = local.create_vpc ? 0 : 1
filter {
name = "vpc-id"
values = [var.vpcId]
}
tags = {
purpose = "public"
}
}
data "aws_subnet" "public_subnet" {
for_each = local.create_vpc ? toset([]) : toset(data.aws_subnets.public_subnets[0].ids)
id = each.value
}