Multiple File Provisioner in Json Terraform
"Provisioner": { "File": { "Connection": { "Private_Key": "${File(\"/Keypair. Pem\")}", "User": "Id" }, "Content": "${Template_File. X1}", "Destination"...
"provisioner": {
"file": {
"connection": {
"private_key": "${file(\"/KeyPair.pem\")}",
"user": "id"
},
"content": "${template_file.x1}",
"destination": "/path/to/dest1"
},
"file": {
"connection": {
"private_key": "${file(\"/KeyPair.pem\")}",
"user": "id"
},
"content": "${template_file.x2}",
"destination": "/path/to/dest2"
}
}
Here I have a JSON Terraform scriplet. I understand I will have to merge/group the file provisioners but I am not too sure how to do that
I keep getting errors whilst validating.
SyntaxError: Duplicate key 'file' on line 78
Do I have to use inline feature?
I think this may be correct. Can anyone confirm?
"file": {
"connection": {
"private_key": "${file(\"/KeyPair.pem\")}",
"user": "id"
},
"content": [
"${template_file.1}",
"${template_file.2}"
],
"destination": [
"/path/dest/",
"/path/dest/"
]
}
1 Answer
Please go through the official sample here
So you should split the codes to two provisioner parts.
"provisioner": {
"file": {
"connection": {
"private_key": "${file(\"/KeyPair.pem\")}",
"user": "id"
},
"content": "${template_file.x1}",
"destination": "/path/to/dest1"
}
}
"provisioner": {
"file": {
"connection": {
"private_key": "${file(\"/KeyPair.pem\")}",
"user": "id"
},
"content": "${template_file.x2}",
"destination": "/path/to/dest2"
}
}
If there are a lot of files to be uploaded, provisioner file supports folder/directory upload. Please go through the details
If you got error message, please paste the detail error, otherwise, it's hard to give the suggestion.