Open ruben-chainalysis opened 1 month ago
I understand the workaround is simple, but finding out how to get there wasn't, so hopefully this issue is found by others or Future Me.
Move the Write Terraform Config file
step below the Setup Terraform
one. Change the line:
cat <<-EOT > "${TF_CLI_CONFIG_FILE}"
to
cat <<-EOT >> "${TF_CLI_CONFIG_FILE}"
so your step appends to the existing file.
You can move the debug step afterwards for a sanity check on your first attempts and it should show the whole config (and any following terraform commands should just work™️ or fail if you had any errors in your custom configuration).
Problem
If we have an existing config file, this action will overwrite it. The debug log line just before the overwrite says
Adding credentials to ${credsFile}
, which adds to the confusion, because it's replacing the existing file (as fs.writeFile does), not adding anything to it.I hit this issue when trying to use a custom provider (or network mirrors). This behaviour makes a static file in the repo hard to use, we end up having to append content to the file this action smashes.
Expected behaviour
If we have custom config in the default location (
${{ github.workspace }}/.terraformrc
) or in a custom one set withTF_CLI_CONFIG_FILE
, the content is preserved and any other configuration is added, not overwritten (at least not by default).If that's too much to ask, at least have clearer debug logs and documentation about this behaviour, because it's a bit painful to get the right outcome.
Steps to reproduce
${{ github.workspace }}/.terraformrc
or in a location that matches the env variableTF_CLI_CONFIG_FILE
. Stick some errors in it if you don't have a network mirror to test, just gibberish that would break any terraform command using the config.setup-terraform
action.terraform init
. It won't honour the config, it won't break if you had any errors.Example