jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
121 stars 52 forks source link

Unexpected / undocumented behaviour of the output command #370

Closed ACavuoto closed 9 months ago

ACavuoto commented 10 months ago

Hi, thanks for supporting this project.

I've installed this extension today and I had some headaches with the behaviour of the output command:

https://github.com/jason-johnson/azure-pipelines-tasks-terraform/blob/6c5d1b5653d5977f2eca16d54e7ea1d7bd929825/tasks/terraform-cli/src/commands/tf-output.ts#L28

The logic here renames the output variables, prepending TF_OUT_ and transforming them to uppercase. This feels like a deliberate choice, which I feel that breaks the implicit WYSIWYG expectation.

I was wondering if you would consider adding a flag (something like RenameOutputVariables, default to true - to avoid breaking changes) to allow developers to get back control of output variable names.

Also, if I may, I feel that documentation should be updated to reflect what this task is actually doing under the hood, as one doesn't necessarily expect that the terraform output CLI command would automatically:

Thanks a lot :)

jason-johnson commented 10 months ago

Well, general Unix convention is that environment variables are in upper case. On Windows agents the variables will be set to uppercase regardless of what we do I believe (I know it works this way with variable groups).

We could make sure the documentation is accurate though. It might be worth considering changing the name of this command to something else since it's not really terraform output exactly.

jason-johnson commented 10 months ago

After looking at the documents: doesn't this describe everything? Are you looking somewhere else that isn't as clear?

ACavuoto commented 9 months ago

Thanks @jason-johnson - It seems that I have missed that section in the documentation, sorry.

I still believe that it would be nice if there was an option to not prepend the TF_OUT_ prefix to the output variables

jason-johnson commented 9 months ago

I'm planning to rework how the output variables are handled because currently they can't be referenced from other jobs or stages. I plan to leave the variables as is for those cases but I will probably need to stick with the TF_OUT_ convention for "within job" variables to avoid a clash.

jason-johnson commented 9 months ago

Closing this one as a duplicate of #36