cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5592
Views
11
Helpful
9
Replies

Win11 changing environment variables API key

halsteadj
Level 2
Level 2

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

Accepted Solutions

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

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 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
Meraki Community All-Star
Meraki Community All-Star

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#M11224

If you found this post helpful, please give it a thumbs up. If my answer solves your problem please click Accept as Solution so others can benefit from it.

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

mloraditch
Meraki Community All-Star
Meraki Community All-Star

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 a thumbs up. If my answer solves your problem please click Accept as Solution so others can benefit from it.

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

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.

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

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 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.

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!

halsteadj
Level 2
Level 2

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.

halsteadj
Level 2
Level 2

hadn't considered PowerShell, thanks