opentofu / setup-opentofu

Mozilla Public License 2.0
89 stars 10 forks source link

Expose the number of changes (import/create/update/delete) via the wrapper #7

Open ilmax opened 1 year ago

ilmax commented 1 year ago

The current wrapper today exposes some output information about the execution of the command.

It would be nice to add some additional output including the number of resources to be:

I for execute some conditions based on those numbers and today I'm getting them parsing the out. I think it would be nice to include them in the setOutput of the wrapper already.

Let me know what you think

kislerdm commented 1 year ago

@ilmax Hey Massimiliano, thank you for your feedback and an interesting proposal. Indeed, the wrapper was implemented to reflect the functionality of the setup-terraform action, but it does not mean that we won't extend its behaviour ;)

For context, the wrapper's features are mostly used to execute tofu commands using GitOps approach, when the tofu user reads the plan before executing the apply command. Moreover, automation of consecutive execution of the commands tofu plan and tofu apply -auto-approve is not recommended.

Could you please illustrate 2-3 use cases when the functionality you proposed would be beneficial?

ilmax commented 1 year ago

Hello @kislerdm and thank you for taking time to answer here.

I'm using the wrapper in PRs to easily get the output of of the plan command and display the result in a message on the PR.

I manually implemented what I suggest here to add a comment in the PR with different colours, no changes means a green comment gets added, if I have create or update resources I use yellow and for delete I use red.

I also was thinking about dynamically adding reviewers to the PR, or triggering some notification if some resources will be deleted or such.

To me using colours helped driving attention where the PR is making some infrastructure changes. Not sure if this meets the bar, I just thought it would be an interesting functionality to add

jschwanz commented 1 year ago

I'm using the wrapper in PRs to easily get the output of of the plan command and display the result in a message on the PR.

We've been using suzuki-shunsuke/tfcmt for that functionality. That's not to say this proposal is not worthwhile, because I think it could be beneficial.

dmlb2000 commented 12 months ago

@kislerdm is there documented concerns about automating plan and apply steps? Looking at other infrastructure as code tools, they can automate the creation resources.

For my specific use case, Azure has specific integrations with GitHub to federate service principals with actions.

https://learn.microsoft.com/en-us/training/paths/bicep-github-actions/

This is for using Bicep but I'm wondering if it will work with OpenTofu.

ilmax commented 12 months ago

Hey @dmlb2000 not sure this is related to this issue, but you can do it with terraform and open tofu as well since it's the provider (i.e. azurerm) that needs to authenticate to azure API, not open tofu itself. I wrote a post a while ago how to set it up, it may help you. You can find it here https://maxdon.tech/posts/github-azure-oidc/