I’m getting this error on build
failed during stage ‘building site’: Environment variable ‘AWS_ACCESS_KEY’ isn’t available for direct interaction
locally, I have this key in a .env file, but Im not pushing it to repository.
How to fix this?
Thanks
luke
February 27, 2020, 8:57am
2
Hi, @Charterfront , and welcome to our Netlify community site.
Have you tried adding this as an environment variable in the Netlify UI? That keeps it out of your repo and still allow the Netlify build system to use it.
If that doesn’t resolve the issue and/or there are other questions, please let us know.
Hi, that’s exactly what I’ve done, and why I’m getting that error. When I remove it from the Netlify UI build & deploy settings, it becomes ok again
luke
February 28, 2020, 9:35am
4
Hi, @Charterfront , would you please send us a link to the deploy with that error?
jen
March 3, 2020, 11:00pm
7
Thanks for sending that over! I believe you’re running into this because AWS_ is a reserved prefix for environment variables. More from @Dennis here:
With regards to env vars, yes, AWS_ prefixed vars are reserved, you can create something like MY_AWS_ prefixed vars instead and explicitly use those variables. You’ll need to check AWS’s documentation on how to pass credentials using specific env vars. Let me know how that goes.
Depending on which AWS service you’re using, there should be docs for custom named vars or passing a config file.
This post describes how to access those vars on the Netlify side:
Last reviewed: August 2023
The preferred way to use environment variables in Netlify is to set them in our environment - be that in the Environment Variables settings UI (on the site’s “Build & Deploy settings” page), or via netlify.toml . You’ll want to choose the right pattern to meet your needs. Setting variables in our UI may be considered a bit more secure, since only people with access to the Netlify admin UI for your site can see them, rather than “anyone who can clone your repo!”.
Thes…
Let us know how it goes or if we can help further!