Skip to content

Commit

Permalink
create module-specific provider subdir before running
Browse files Browse the repository at this point in the history
Terraform expects the directory to already exist and will not create it.
  • Loading branch information
lilatomic committed Jan 19, 2025
1 parent c3b67fa commit 9d22f89
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/python/pants/backend/terraform/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
ExternalToolRequest,
TemplatedExternalTool,
)
from pants.core.util_rules.system_binaries import MkdirBinary
from pants.engine.env_vars import EXTRA_ENV_VARS_USAGE_HELP, EnvironmentVars, EnvironmentVarsRequest
from pants.engine.fs import EMPTY_DIGEST, Digest
from pants.engine.internals.selectors import Get
from pants.engine.platform import Platform
from pants.engine.process import Process
from pants.engine.process import Process, FallibleProcessResult
from pants.engine.rules import collect_rules, rule
from pants.engine.unions import UnionRule
from pants.option.option_types import ArgsListOption, BoolOption, StrListOption
Expand Down Expand Up @@ -451,6 +452,14 @@ async def setup_terraform_process(
def prepend_paths(paths: Tuple[str, ...]) -> Tuple[str, ...]:
return tuple((Path(request.chdir) / path).as_posix() for path in paths)

# Initialise the Terraform provider cache, since Terraform expects the directory to already exist.
await Get(FallibleProcessResult, Process(
argv=[mkdir.path, "-p", tf_plugin_cache_dir],
append_only_caches=terraform.append_only_caches,
description="initialise Terraform plugin cache dir",
level=LogLevel.DEBUG,
))

return Process(
argv=("__terraform/terraform", f"-chdir={shlex.quote(request.chdir)}") + request.args,
input_digest=request.input_digest,
Expand Down

0 comments on commit 9d22f89

Please sign in to comment.