Skip to content

Commit 47907ae

Browse files
committed
Allow outputting additional TF outputs
1 parent c4b5605 commit 47907ae

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

class/defaults.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ parameters:
1212
git: {}
1313
provider: ${facts:cloud}
1414
version: ${openshift4_terraform:_tf_module_version:${openshift4_terraform:provider}}
15+
additional_outputs: {}
1516
terraform_variables:
1617
source: git::https://github.com/appuio/terraform-openshift4-${openshift4_terraform:provider}.git//?ref=${openshift4_terraform:version}
1718
cluster_id: ${cluster:name}

component/main.jsonnet

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,13 @@ local terraform_config =
7474
},
7575
},
7676
},
77+
local mergedOutputs = params.additional_outputs + outputs[params.provider],
7778
'outputs.tf': {
7879
output: {
7980
[out]: {
80-
value: outputs[params.provider][out],
81+
value: mergedOutputs[out],
8182
}
82-
for out in std.objectFields(outputs[params.provider])
83+
for out in std.objectFields(mergedOutputs)
8384
},
8485
},
8586
'variables.tf': {

docs/modules/ROOT/pages/references/parameters.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ Terraform input variables for the selected Terraform module (see parameter `prov
6262
They're passed to the module without any further processing.
6363
The variables are merged with the defaults, unless overridden.
6464

65+
66+
== `additional_outputs`
67+
68+
[horizontal]
69+
type:: object
70+
default:: `{}`
71+
example::
72+
+
73+
[source,yaml]
74+
----
75+
additional_outputs:
76+
my_output: '\${module.cluster.my_output}'
77+
----
78+
79+
Additional outputs that are passed to the Terraform module.
80+
The outputs are merged with the defaults, defaults can't be overridden.
81+
The keys are then name of the output, the value should contain a reference to a output variable from the Terraform module.
82+
Additional escaping might be needed since Terraform variables use the same syntax as reclass; see the example above.
83+
84+
6585
== `version`
6686

6787
[horizontal]

tests/cloudscale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ parameters:
1414
- ssh-ed25519 AA...
1515
control_vshn_net_token: asdf...
1616
hieradata_repo_user: project_123_bot
17+
additional_outputs:
18+
region: '\${module.cluster.region}'

tests/golden/cloudscale/openshift4-terraform/openshift4-terraform/outputs.tf.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
},
66
"hieradata_mr": {
77
"value": "${module.cluster.hieradata_mr}"
8+
},
9+
"region": {
10+
"value": "${module.cluster.region}"
811
}
912
}
1013
}

0 commit comments

Comments
 (0)