terraform-google-modules / terraform-docs-samples

Terraform samples intended for inclusion in cloud.google.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instead of adding the functions inside of a zip file, could we instead add the files in a sub-directory and then use the `archive_file` terraform resource?

bharathkkb opened this issue · comments

Re: function-source.zip - instead of adding the functions inside of a zip file, could we instead add the files in a sub-directory and then use the archive_file terraform resource?

For example, move index.js and package.json to functions/hello-world/ and then:

data "archive_file" "archive" {
  type        = "zip"
  output_path = "/tmp/function-source.zip"
  source_dir  = "functions/hello-world"
}
resource "google_storage_bucket_object" "object" {
  name   = "function-source.zip"
  bucket = google_storage_bucket.bucket.name
  source = data.archive_file.archive.output_path  # Add path to the zipped function source code
}

It adds a little more complexity to the sample but could be useful for showing one method of including those functions in source control along side their terraformed cloud function resources.

Originally posted by @rogerthatdev in #143 (comment)

Just +1 this as it is a more realistic use case.