-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.tf
executable file
·80 lines (68 loc) · 2.94 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
locals {
cloudfoundry = {
external_applications = try(data.cloudfoundry_app.external_applications, null)
domain_external = try(data.cloudfoundry_domain.external, null)
domain_internal = try(data.cloudfoundry_domain.internal, null)
egress_app = try(data.cloudfoundry_app.egress_proxy[0], null)
egress_space = try(data.cloudfoundry_space.egress_proxy[0], null)
egress_route = try(data.cloudfoundry_route.egress_proxy[0], {})
organization = try(data.cloudfoundry_org.this, null)
services = try(data.cloudfoundry_service.this, null)
space = try(data.cloudfoundry_space.this[0], null)
}
}
data "cloudfoundry_app" "external_applications" {
for_each = {
for key, value in try(local.env.external_applications, {}) : key => value
if try(value.deployed, false) &&
try(data.cloudfoundry_space.this[0].id, null) != null
}
name_or_id = format(local.env.name_pattern, each.key)
space = try(data.cloudfoundry_space.this[0].id, null)
}
data "cloudfoundry_domain" "external" {
domain = "${split(".", local.env.external_domain)[1]}.${split(".", local.env.external_domain)[2]}"
sub_domain = split(".", local.env.external_domain)[0]
}
data "cloudfoundry_domain" "internal" {
domain = split(".", local.env.internal_domain)[1]
sub_domain = split(".", local.env.internal_domain)[0]
}
data "cloudfoundry_org" "this" {
name = local.env.organization
}
data "cloudfoundry_space" "this" {
count = terraform.workspace != local.env.bootstrap_workspace ? 1 : 0
name = try(local.env.space, terraform.workspace)
org = data.cloudfoundry_org.this.id
}
data "cloudfoundry_service" "this" {
for_each = {
for key, value in try(local.env.services, {}) : key => value
if value.service_type != "user-provided" &&
try(data.cloudfoundry_space.this[0].id, null) != null
}
name = each.value.service_type
space = try(data.cloudfoundry_space.this[0].id, null)
}
data "cloudfoundry_space" "egress_proxy" {
count = terraform.workspace != local.env.egress.workspace && terraform.workspace != local.env.bootstrap_workspace ? 1 : 0
name = local.env.egress.space
org = data.cloudfoundry_org.this.id
}
data "cloudfoundry_app" "egress_proxy" {
count = terraform.workspace != local.env.egress.workspace && terraform.workspace != local.env.bootstrap_workspace ? 1 : 0
name_or_id = format(local.env.egress.name_pattern, local.env.egress.name)
space = data.cloudfoundry_space.egress_proxy[0].id
}
data "cloudfoundry_route" "egress_proxy" {
count = terraform.workspace != local.env.egress.workspace && terraform.workspace != local.env.bootstrap_workspace ? 1 : 0
domain = data.cloudfoundry_domain.internal.id
hostname = data.cloudfoundry_app.egress_proxy[0].name
}
data "http" "cloudfront_ips_json" {
url = "https://d7uri8nf7uskq.cloudfront.net/tools/list-cloudfront-ips"
request_headers = {
Accept = "application/json"
}
}