Open Mornor opened 5 months ago
Hi @Mornor, the issue is the forward slash, right?
Yes, it should work with a forward slash (so a full path) like so
tg_command: plan -out {{ github.workspace }}/terragrunt.tfplan
tg_command: plan -out "{{ github.workspace }}/terragrunt.tfplan"
tg_command: plan -out $(pwd)/terragrunt.tfplan
But it doesn't (Error: Failed to write plan file ...
).
However, this works (without forward slash)
tg_command: plan -out $(pwd)terragrunt.tfplan
IMO, we should be able to give a full path for the plan file as output.
@Mornor, -out
is a terraform flag, Terragrunt simply passes this flag to Terraform when running the terraform plan
command. You should create this issue in Terraform issues.
The corresponding command (terraform plan -out terraform.tfplan)
works fine.
Locally issuing following command works as well, so this make me think the issue is related to the Terragrunt GH Action itself
$> rm -rf $(pwd)/terragrunt.tfplan
$> terragrunt plan -out $(pwd)/terragrunt.tfplan
No changes. Your infrastructure matches the configuration.
$> terragrunt show $(pwd)/terragrunt.tfplan
No changes. Your infrastructure matches the configuration.
However, it seems the terragrunt command itself doesn't work as expected. Locally, this does not produce any plan.
$> terragrunt plan -out terragrunt.tfplan
But this does
$> terragrunt plan -out $(pwd)/terragrunt.tfplan
However, not with Github Action (Error: Failed to write plan file [...] terragrunt.tfplan: no such file or │ directory
This might be related to a core Terragrunt issue.
Hi,
AFAIK, *workspace
variables in case of runners point to the wrong locations, use /github/workspace
path to save/load plan files
In my tests:
github.workspace = /home/runner/work/terragrunt-tests/terragrunt-tests
GITHUB_WORKSPACE = /home/runner/work/terragrunt-tests/terragrunt-tests
runner.workspace = /home/runner/work/terragrunt-tests
RUNNER_WORKSPACE = /home/runner/work/terragrunt-tests
when during execution, working directory is mounted in /github/workspace
Hi @denis256,
Big up to you, as I managed to make it work with a combination of your solution and some mv
commands:
- name: Plan
uses: gruntwork-io/terragrunt-action@v2
with:
tf_version: ${{ inputs.tf_version }}
tg_version: ${{ inputs.tg_version }}
tg_dir: ${{ inputs.customer_dir }}/${{ inputs.customer }}/${{ inputs.dir_to_deploy }}
tg_command: plan -out /github/workspace/terragrunt.tfplan
- name: Move plan file
working-directory: ${{ github.workspace }}
run: mv terragrunt.tfplan ${{ inputs.customer_dir }}/${{ inputs.customer }}/${{ inputs.dir_to_deploy }}/terragrunt.tfplan
I don't really like or understand the combination of {{ github.workspace }}
and /github/workspace/
(and I still think there's something not working properly under the hood), but at least it works!
Describe the bug The following commands fails to redirect the plan file
To Reproduce
Expected behavior
Actual behaviour
Other notes The following command works
But I would expect one of these commands to work instead
Nice to have
Versions
terragrunt-action@v2
Related Might be related to #40