Is there anyway i can use terraform to copy folders from local server to Google storage bucket?
I have tried file provisioner, but it is only working for VM instance, but not cloud storage.
Another possibility to upload a group of files to a bucket
variable "files" {
type = map(string)
default = {
# sourcefile = destfile
"folder/file1" = "somefolder/file1",
"folder2/file2" = "somefolder/file2"
}
}
resource "google_storage_bucket_object" "my-config-objects" {
for_each = var.files
name = each.value
source = "${path.module}/${each.key}"
bucket = my-bucket-name
}
It appear that there is a command called google_storage_bucket_object
which will copy a local file to a GCS object.
See here for details:
https://www.terraform.io/docs/providers/google/r/storage_bucket_object.html
Another thought might be to run the local-exec
provisioner and run gsutil to copy a directory of files.
https://www.terraform.io/docs/provisioners/local-exec.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With