---
description: |
  The `file` builder creates an artifact from a file. Use the `file` builder to debug post-processors without incurring long wait times.
page_title: file builder reference
---

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
> [!IMPORTANT]  
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

<BadgesHeader>
  <PluginBadge type="official" />
</BadgesHeader>

# `file` builder

The `file` builder creates an artifact from a file. You can use it to debug post-processors without incurring long wait times.

Artifact `BuilderId`: `packer.file`

## Basic Example

Below is a fully functioning example. It create a file at `target` with the
specified `content`.

<Tabs>
<Tab heading="HCL2">

```hcl
source "file" "basic-example" {
  content =  "Lorem ipsum dolor sit amet"
  target =  "dummy_artifact"
}

build {
  sources = ["sources.file.basic-example"]
}
```

</Tab>
<Tab heading="JSON">

```json
{
  "type": "file",
  "content": "Lorem ipsum dolor sit amet",
  "target": "dummy_artifact"
}
```

</Tab>
</Tabs>

## Configuration Reference

Configuration options are organized below into two categories: required and
optional. Within each category, the available options are alphabetized and
described.

Any [communicator](/packer/docs/templates/legacy_json_templates/communicator) defined is ignored.

### Required

- `target` (string) - The path for the artifact file that will be created. If
  the path contains directories that don't exist, Packer will create them, too.

### Optional

You can only define one of `source` or `content`. If none of them is defined
the artifact will be empty.

- `source` (string) - The path for a file which will be copied as the
  artifact.

- `content` (string) - The content that will be put into the artifact.
