Win11 changing environment variables API key

Solved
NetEngJH
Getting noticed

Win11 changing environment variables API key

I am using the Meraki Terraform provider to make changes to our Dashboards. We have one in Europe and one in China.  Every time I want to make a change I have to change my user environment variables API key, then reboot on Win11.  Does anyone know of a way to update API keys like this without having to do a reboot?

1 Accepted Solution
alemabrahao
Kind of a big deal
Kind of a big deal

Hi,

 

You can update environment variables in Windows 11 without rebooting your system. 

 

Try this:

Open Command Prompt as an administrator.
Run the command setx API_KEY "your_new_api_key".
To refresh the environment variables, run the command refreshenv

 

Refresh Environment Variables in Windows 11 (Without Reboot)

 

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

View solution in original post

9 Replies 9
Mloraditch
Kind of a big deal
Kind of a big deal

I'm guessing you are storing it in a system variable? Take a look at this post, technically it's Linux but you should be able to store the variable somewhere else: https://community.meraki.com/t5/Developers-APIs/MERAKI-API-KEY-Environment-Variable/m-p/246099#M1122...

If you found this post helpful, please give it Kudos. If my answer solves your problem please click Accept as Solution so others can benefit from it.
NetEngJH
Getting noticed

It's the environment variables for the user account rather than system.  Sadly that link doesn't help much I'm afraid.

Mloraditch
Kind of a big deal
Kind of a big deal

Here's a general document on how terraform uses variables: https://spacelift.io/blog/how-to-use-terraform-variables#variable-substitution-using-cli-and-tfvars that also may help you adjust your runs and If not I have to imagine someone else will be able to answer more directly soon. 

If you found this post helpful, please give it Kudos. If my answer solves your problem please click Accept as Solution so others can benefit from it.
PhilipDAth
Kind of a big deal
Kind of a big deal

I'm not familiar with Terraform, but check out dotenv.  That lets you persistently store API keys.

 

I did have a post about using it many years ago, but alas, it appears to have been archived now.

PhilipDAth
Kind of a big deal
Kind of a big deal
alemabrahao
Kind of a big deal
Kind of a big deal

Hi,

 

You can update environment variables in Windows 11 without rebooting your system. 

 

Try this:

Open Command Prompt as an administrator.
Run the command setx API_KEY "your_new_api_key".
To refresh the environment variables, run the command refreshenv

 

Refresh Environment Variables in Windows 11 (Without Reboot)

 

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
NetEngJH
Getting noticed

Thanks a lot for replying, using "refreshenv" after updating the API keys, then restarting my Visual Studio sorts this out.  Saves me a time consuming reboot!

NetEngJH
Getting noticed

I had the same idea.  However the risk of leaking the API credentials to GitHub was too big with that approach, so opted for keeping API keys out of the actual Terraform files.

NetEngJH
Getting noticed

hadn't considered PowerShell, thanks

Get notified when there are additional replies to this discussion.