Skip to content

Commit 0c8bf27

Browse files
authored
Update generated example library content (#159)
2 parents 64504f4 + d738cf9 commit 0c8bf27

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

resource-definitions/template-driver/serviceaccount/serviceaccount-k8ssa-def.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ resource "humanitec_resource_definition" "serviceaccount-k8s-service-account" {
77
values_string = jsonencode({
88
"res_id" = "$${context.res.id}"
99
"templates" = {
10-
"init" = "name: {{ index ( .driver.values.res_id | splitList \".\" ) 1 }}\n"
10+
"init" = <<END_OF_TEXT
11+
res_id: {{ .driver.values.res_id }}
12+
{{- $res_name := .driver.values.res_id | splitList "." | last }}
13+
name: {{ $res_name | toRawJson }}
14+
END_OF_TEXT
1115
"outputs" = "name: {{ .init.name }}\n"
1216
"manifests" = <<END_OF_TEXT
1317
service-account.yaml:
@@ -17,6 +21,8 @@ service-account.yaml:
1721
kind: ServiceAccount
1822
metadata:
1923
name: {{ .init.name }}
24+
annotations:
25+
hum-res: {{ .init.res_id }}
2026
END_OF_TEXT
2127
}
2228
})

resource-definitions/template-driver/serviceaccount/serviceaccount-workload-def.tf

+3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ resource "humanitec_resource_definition" "serviceaccount-workload" {
1010
update:
1111
- op: add
1212
path: /spec/serviceAccountName
13+
# Option 1: separate ServiceAccount per workload. Using the current workload's ID by not specifying an ID
1314
value: $${resources.k8s-service-account.outputs.name}
15+
# Option 2: single ServiceAccount for all workloads. Specifying a fixed ID, e.g. "ksa"
16+
# value: $${resources.k8s-service-account#ksa.outputs.name}
1417
END_OF_TEXT
1518
}
1619
})

0 commit comments

Comments
 (0)