Artifacts

Artifacts Lazy Download

Artifacts are the outputs generated by a build process. In many cases, your project may depend on internal artifacts — for example, a shared library used by an application.

Terrabuild automatically manages artifacts to support partial builds. This means:

  • If the library hasn’t changed, there is no need to rebuild it.
  • However, it may still be required to build the application.
  • If both the library and the application haven’t changed, then there’s no need to download any artifacts.

To optimize performance and reduce unnecessary operations, artifacts are only downloaded on-demand, and only once. This approach can result in significant performance gains. However, if you really want artifacts to be downloaded, you can still set restore = true on targets.

Ephemeral Artifacts

In most cases, artifacts are managed directly by Terrabuild and lifetime is infinite. However, there are exceptions — such as:

  • Terraform: where state is stored in a remote backend and lifetime is subject to global state of the infrastructure (see staled plan).

The rationale is that such target - despite being cached - as a short validity. This is why, ephemeral targets are always retried regardless of a positive completion.

For example:

# generate terraform artifacts
target plan {
    ephemeral = true
    depends_on = [ target.^dist
                   target.^plan ]
}
Last updated on