archive_file (Data Source)

Generates an archive from content, a file, or directory of files.

Example Usage

# Archive a single file.

data "archive_file" "init" {
  type        = "zip"
  source_file = "${path.module}/init.tpl"
  output_path = "${path.module}/files/init.zip"
}
# Archive multiple files and exclude file.

data "archive_file" "dotfiles" {
  type        = "zip"
  output_path = "${path.module}/files/dotfiles.zip"
  excludes    = ["${path.module}/unwanted.zip"]

  source {
    content  = data.template_file.vimrc.rendered
    filename = ".vimrc"
  }

  source {
    content  = data.template_file.ssh_config.rendered
    filename = ".ssh/config"
  }
}
# Archive a file to be used with Lambda using consistent file mode

data "archive_file" "lambda_my_function" {
  type             = "zip"
  source_file      = "${path.module}/../lambda/my-function/index.js"
  output_file_mode = "0666"
  output_path      = "${path.module}/files/lambda-my-function.js.zip"
}

Schema

Required

Optional

Read-Only

Nested Schema for source

Required: