terraformterraform-cloud

Terraform parent directory uploads issue


When using running terraform in remote execution mode, terraform uploads the content of the configuration directory to terraform cloud. In my case, the content of the infrastructure directory gets uploaded:

functions
  function-a.zip
  function-b.zip
  ...
infrastructure
  main.tf
  ...

I have some terraform modules inside the infrastructure folder that are referencing binary files (zip files) that live outside the terraform config directory. These are build artifacts that are created prior to executing terraform. The issue is that those zip files are not copied over when executing terraform remotely which obviously causes some errors.

Is there a way to ensure that my zip files get uploaded to terraform cloud without having to put them inside the config directory?


Solution

  • Thanks to @paulg, I was able to selectively upload my function artifacts using a symlink.

    Here's what my new folder structure looks like:

    functions
      function-a.zip
      function-b.zip
      ...
    infrastructure
      artifacts
        functions (symlink to ../../functions)
      main.tf
      ...
    

    The only thing I needed to do after that was to adjust my modules to reference my function artifacts through the symlink.