Using TerraformAsset with files when planning and applying run in separate containers

Last updated: September 16, 2025

When using TerraformAsset to zip and upload files (such as Lambda source code) in Terraform, you may encounter issues where the planning phase works correctly but the apply phase fails because it cannot find the required files.

This happens because when a run resumes after being paused (for example, for confirmation or approval), the remaining phases run in a new container. Any files or tools from earlier phases will not be available in the new container.

Solutions

There are two main approaches to resolve this issue:

Option 1: Use a Custom Runner Image

Bake the required tools and files into a custom runner image. This ensures that all necessary dependencies are available in both the planning and apply phases.

Option 2: Use Before Apply Hooks

You can use the same hooks that you used in earlier phases within the before_apply hook. This allows you to recreate or download the necessary files before the apply phase runs.

Additional Information

For more details about customizing workflows and understanding how different phases work in separate containers, refer to the workflow customization documentation.