forked from GoogleCloudPlatform/cloud-foundation-fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputs-files.tf
More file actions
78 lines (70 loc) · 3.22 KB
/
outputs-files.tf
File metadata and controls
78 lines (70 loc) · 3.22 KB
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
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
# tfdoc:file:description Output files persistence to local filesystem.
resource "local_file" "providers-simple" {
for_each = var.outputs_location == null ? {} : {
for k, v in local.tenants : k => local.tenant_data[k]
}
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/providers/${var.names.output_files_prefix}-${each.key}.tf"
content = templatefile(local._tpl_providers, {
backend_extra = null
bucket = each.value.gcs_bucket
name = each.key
sa = each.value.service_account
})
}
resource "local_file" "tfvars-simple" {
for_each = var.outputs_location == null ? {} : {
for k, v in local.tenants : k => local.tenant_data[k]
}
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/tfvars/${var.names.output_files_prefix}-${each.key}.auto.tfvars.json"
content = jsonencode(each.value)
}
resource "local_file" "providers" {
for_each = var.outputs_location == null ? {} : local.tenant_providers
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/${var.names.output_files_prefix}/${each.key}/providers/1-resman-providers.tf"
content = try(each.value, null)
}
resource "local_file" "providers-r" {
for_each = var.outputs_location == null ? {} : local.tenant_providers_r
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/${var.names.output_files_prefix}/${each.key}/providers/1-resman-r-providers.tf"
content = try(each.value, null)
}
resource "local_file" "tfvars" {
# work around Terraform's botched ternary type check on maps
for_each = {
for k, v in local.tenant_tfvars : k => v if var.outputs_location != null
}
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/${var.names.output_files_prefix}/${each.key}/tfvars/0-bootstrap.auto.tfvars.json"
content = jsonencode(each.value)
}
resource "local_file" "tfvars_globals" {
for_each = var.outputs_location == null ? {} : local.tenant_globals
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/${var.names.output_files_prefix}/${each.key}/tfvars/0-globals.auto.tfvars.json"
content = jsonencode(each.value)
}
resource "local_file" "workflows" {
for_each = var.outputs_location == null ? {} : local.tenant_cicd_workflows
file_permission = "0644"
filename = "${try(pathexpand(var.outputs_location), "")}/${var.names.output_files_prefix}/${each.key}/workflows/1-resman-workflow.yaml"
content = try(each.value, null)
}