I'm trying to find the best way to create large knowledge bases. A document can't be published without variation, which is understandable and the provider throws an error at the document creation if the published flag is true, but the document is created as draft and is not added to the state, which is weird and could lead to duplicate values.
I think the document shouldn't be created, or should be added to the state.
PS C:\essais> terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# genesyscloud_knowledge_document.essai_1 will be created
+ resource "genesyscloud_knowledge_document" "essai_1" {
+ id = (known after apply)
+ knowledge_base_id = (known after apply)
+ published = true
+ knowledge_document {
+ label_names = []
+ title = "Essai 1"
+ visible = true
# (1 unchanged attribute hidden)
+ alternatives {
+ autocomplete = false
+ phrase = "Essai 1"
}
}
}
# genesyscloud_knowledge_document_variation.essai_1 will be created
+ resource "genesyscloud_knowledge_document_variation" "essai_1" {
+ id = (known after apply)
+ knowledge_base_id = (known after apply)
+ knowledge_document_id = (known after apply)
+ published = true
+ knowledge_document_variation {
+ body {
+ blocks {
+ type = "Paragraph"
+ paragraph {
+ blocks {
+ type = "Text"
+ text {
+ text = "Essai 1."
}
}
}
}
}
}
}
# genesyscloud_knowledge_knowledgebase.essai will be created
+ resource "genesyscloud_knowledge_knowledgebase" "essai" {
+ core_language = "fr-FR"
+ id = (known after apply)
+ name = "Essai"
# (1 unchanged attribute hidden)
}
Plan: 3 to add, 0 to change, 0 to destroy.
Do you want to perform these actions in workspace "dev"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
genesyscloud_knowledge_knowledgebase.essai: Creating...
genesyscloud_knowledge_knowledgebase.essai: Creation complete after 5s [id=bf16b32e-b1a6-49e6-ba07-87df91ff9f4e]
genesyscloud_knowledge_document.essai_1: Creating...
╷
│ Error: Failed to publish knowledge document error: %!s(<nil>)
│
│ with genesyscloud_knowledge_document.essai_1,
│ on resources_knowledge_documents.tf line 1, in resource "genesyscloud_knowledge_document" "essai_1":
│ 1: resource "genesyscloud_knowledge_document" "essai_1" {
│
│ {"resourceName":"genesyscloud_knowledge_document","method":"POST","path":"/api/v2/knowledge/knowledgebases/bf16b32e-b1a6-49e6-ba07-87df91ff9f4e/documents/31f71e4d-3db4-4f06-8480-6033855dd142/versions","statusCode":400,"errorMessage":"API
│ Error: 400 - Document 31f71e4d-3db4-4f06-8480-6033855dd142 has no variation, which is mandatory to publish a document
│ (c54e2480-8184-4d90-8a3b-6835cd16628d)","correlationId":"c54e2480-8184-4d90-8a3b-6835cd16628d"}
╵
PS C:\essais> terraform state list
genesyscloud_knowledge_knowledgebase.essai
Hi,
I'm trying to find the best way to create large knowledge bases. A document can't be published without variation, which is understandable and the provider throws an error at the document creation if the published flag is true, but the document is created as draft and is not added to the state, which is weird and could lead to duplicate values.
I think the document shouldn't be created, or should be added to the state.
Here is the example:
And the command line results: