Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ilmax opened this issue Oct 19, 2023 · 5 comments
Open

Comments

@ilmax
Copy link

ilmax commented Oct 19, 2023

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:

  • imported
  • created
  • modified
  • deleted

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
Copy link
Contributor

kislerdm commented Oct 19, 2023

@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
Copy link
Author

ilmax commented Oct 19, 2023

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
Copy link

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
Copy link

@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
Copy link
Author

ilmax commented Nov 29, 2023

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants