2016-08-08 02:56:44 +02:00
|
|
|
---
|
|
|
|
layout: "archive"
|
|
|
|
page_title: "Archive: archive_file"
|
2016-10-25 16:59:06 +02:00
|
|
|
sidebar_current: "docs-archive-datasource-archive-file"
|
2016-08-08 02:56:44 +02:00
|
|
|
description: |-
|
|
|
|
Generates an archive from content, a file, or directory of files.
|
|
|
|
---
|
|
|
|
|
2017-04-06 20:07:15 +02:00
|
|
|
# archive_file
|
2016-08-08 02:56:44 +02:00
|
|
|
|
|
|
|
Generates an archive from content, a file, or directory of files.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-06 20:07:15 +02:00
|
|
|
```hcl
|
2017-05-17 19:41:25 +02:00
|
|
|
# Archive a single file.
|
|
|
|
|
2016-10-25 16:59:06 +02:00
|
|
|
data "archive_file" "init" {
|
2017-04-06 20:07:15 +02:00
|
|
|
type = "zip"
|
|
|
|
source_file = "${path.module}/init.tpl"
|
|
|
|
output_path = "${path.module}/files/init.zip"
|
2016-08-08 02:56:44 +02:00
|
|
|
}
|
2017-05-17 19:41:25 +02:00
|
|
|
|
|
|
|
# Archive multiple files.
|
|
|
|
|
|
|
|
data "archive_file" "dotfiles" {
|
|
|
|
type = "zip"
|
|
|
|
output_path = "${path.module}/files/dotfiles.zip"
|
|
|
|
|
|
|
|
source {
|
|
|
|
content = "${data.template_file.vimrc.rendered}"
|
|
|
|
filename = ".vimrc"
|
|
|
|
}
|
|
|
|
|
|
|
|
source {
|
|
|
|
content = "${data.template_file.ssh_config.rendered}"
|
|
|
|
filename = ".ssh/config"
|
|
|
|
}
|
|
|
|
}
|
2016-08-08 02:56:44 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
NOTE: One of `source`, `source_content_filename` (with `source_content`), `source_file`, or `source_dir` must be specified.
|
2016-08-08 02:56:44 +02:00
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
* `type` - (Required) The type of archive to generate.
|
2016-08-22 14:27:43 +02:00
|
|
|
NOTE: `zip` is supported.
|
2016-08-08 02:56:44 +02:00
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
* `output_path` - (Required) The output of the archive file.
|
|
|
|
|
|
|
|
* `source_content` - (Optional) Add only this content to the archive with `source_content_filename` as the filename.
|
|
|
|
|
|
|
|
* `source_content_filename` - (Optional) Set this as the filename when using `source_content`.
|
|
|
|
|
|
|
|
* `source_file` - (Optional) Package this file into the archive.
|
|
|
|
|
|
|
|
* `source_dir` - (Optional) Package entire contents of this directory into the archive.
|
2016-08-08 02:56:44 +02:00
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
* `source` - (Optional) Specifies attributes of a single source file to include into the archive.
|
2016-08-08 02:56:44 +02:00
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
The `source` block supports the following:
|
2016-08-08 02:56:44 +02:00
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
* `content` - (Required) Add this content to the archive with `filename` as the filename.
|
2016-08-08 02:56:44 +02:00
|
|
|
|
2017-05-17 19:41:25 +02:00
|
|
|
* `filename` - (Required) Set this as the filename when declaring a `source`.
|
2016-08-08 02:56:44 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `output_size` - The size of the output archive file.
|
2016-10-25 16:59:06 +02:00
|
|
|
|
2016-08-08 02:56:44 +02:00
|
|
|
* `output_sha` - The SHA1 checksum of output archive file.
|
2016-10-25 16:59:06 +02:00
|
|
|
|
|
|
|
* `output_base64sha256` - The base64-encoded SHA256 checksum of output archive file.
|
2016-12-20 03:39:38 +01:00
|
|
|
|
|
|
|
* `output_md5` - The MD5 checksum of output archive file.
|