@@ -8,16 +8,34 @@ This gives you the flexibility of parameterizing your manifests, and loading & t
88
99## Example Usage
1010
11- ### Load all manifest documents
11+ ### Load all manifest documents via for_each (recommended)
12+
13+ The recommended approach is to use the ` manifests ` attribute and a ` for_each ` expression to apply the found manifests.
14+ This ensures that any additional yaml documents or removals do not cause a large amount of terraform changes.
1215
1316``` hcl
14- data "kubectl_path_documents" "manifests" {
17+ data "kubectl_path_documents" "docs" {
18+ pattern = "./manifests/*.yaml"
19+ }
20+
21+ resource "kubectl_manifest" "test" {
22+ for_each = data.kubectl_file_documents.docs.manifests
23+ yaml_body = each.value
24+ }
25+ ```
26+
27+ ### Load all manifest documents via count
28+
29+ Raw documents can also be accessed via the ` documents ` attribute.
30+
31+ ``` hcl
32+ data "kubectl_path_documents" "docs" {
1533 pattern = "./manifests/*.yaml"
1634}
1735
1836resource "kubectl_manifest" "test" {
19- count = length(data.kubectl_path_documents.manifests .documents)
20- yaml_body = element(data.kubectl_path_documents.manifests .documents, count.index)
37+ count = length(data.kubectl_path_documents.docs .documents)
38+ yaml_body = element(data.kubectl_path_documents.docs .documents, count.index)
2139}
2240```
2341
@@ -152,4 +170,5 @@ metadata:
152170
153171## Attribute Reference
154172
155- * ` documents ` - List of YAML documents (list[ string] ).
173+ * ` manifests ` - Map of YAML documents with key being the document id, and value being the document yaml. Best used with ` for_each ` expressions.
174+ * ` documents ` - List of YAML documents (list[ string] ). Best used with ` count ` expressions.
0 commit comments