How do I archive file/dir from a gitlab repository using Terraform?

Viewed 1004

I need to archive a directory from my gitlab repo using terraform in order to use the ZIP file in an aws lambda function. when putting a url in the source attribute it errors: Error: error archiving file: could not archive missing file: https://*********/lambda.py

my Terraform code for archiving the file is:

data "archive_file" "init" {
   type        = "zip"
   output_path = "${path.module}/example.zip"
   source_file = "https://*********/lambda.py"
}

so obviously this is not the right way to do it, didn't find anything regarding this online, is there a proper way to do this using Terraform?

2 Answers

source_file is a local path, not a remote url. Thus you can do:

  1. Download your file from github using null_resource with local_exec as shown here.
  2. Use your archive_file to archive the newly downloaded file from github.
Related