How to set up environment variable for Terraform on Windows for NSX-T

We are using GitHub as our repository for NSX-T and Terraform to apply changes in our vSphere environment. After change is review and merged to main branch it needs to be applied.

To apply changes to NSX-T it is simple command:

terrafrom apply

However I forgot to add user name and password for NSX-T

In terraform to set variables there is a command EXPORT, however if you are running your Terraform deployments on VS Code or PowerShell on Windows OS, EXPORT command doesn’t work. PS $format doesn’t work either.

Here is a snippet which will work:

Set-Item -Path env:NSXT_USERNAME -Value 'user_name'
Set-Item -Path env:NSXT_PASSWORD -Value 'password'

After setting up those variables the change went successfully.

Please like and share to spread the knowledge in the community.

If you want to chat with me please use Twitter: @AngrySysOps

Visit my FB page: https://www.facebook.com/AngrySysOps

Read my blog: https://angrysysops.com

Subscribe to my channel : https://www.youtube.com/channel/UCRTcKGl0neismSRpDMK_M4A

Please leave the comment