jtopjian / terraform-provider-sensu

A Terraform provider for Sensu Go
21 stars 11 forks source link

Change user password #39

Open lucas1sanz opened 4 years ago

lucas1sanz commented 4 years ago

Hi! First of all I want to than you for your work, this terraform provider has greatly simplified my workflow.

I would like to let you know one small issue I have experienced.

The process I have followed to encounter this issue is:

  1. Deploy sensu
  2. Apply configuration with terraform, changing the default user agent password to one of my choosing
  3. Delete sensu deployment and deploy again without persisting the past configuration (a clean installation)
  4. Apply the configuration with terraform

This creates two situations:

  1. terraform plan outputs there are no changes to the user, even though the default agent password is in place, not the one I want. This is due to the fact that terraform knows the password of the tfstate but not the actual password of the user agent
  2. If I change the password, terraform plan correctly outputs a change in the user, and terraform apply succeds. But the password of the user is not changed, because the call to the API endpoint /api/core/v2/users/agent/password is done with the password stored in the tfstate instead of the default/correct one

One way to mitigate this issue would be to attempt to login with the API endpoint /auth with the stored credentials in the tfstate before actually applying the change. If the login doesn't succeed, try with the default password.

I understand this is a very edge case and not really an important issue, I just wanted to bring it to your attention.

Feel free to close this issue if you view it as an extremely rare case and have a great day!