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.

Unmanaged Artifacts

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

  • Terraform: where state is stored in a remote backend.
  • Docker: where images are pushed to a registry.

From an I/O perspective, it is often not worthwhile to restore local copies of these artifacts, since the essential data resides outside of Terrabuild’s scope.

Unfortunately, this cannot be automatically determined. A task may involve a mix of commands that produce both managed and unmanaged artifacts.

By default, Terrabuild is conservative and restores all artifacts.
However, this behavior can be overridden on a per-task basis by setting the managed attribute either at the workspace or project level.

if managed is false, then artifacts are not downloaded, leading to much faster builds.

⚠️
Be sure to understand consequences if artifacts are not downloaded.

For example:

# generate docker artifacts
target dist {
    managed = false
    depends_on = [ target.build
                   target.^dist ]
}
Last updated on