![background](/_next/static/media/bg-background-blur-blue.f54782df.webp)
![radial](/_next/static/media/leftRadialLatestBlog.10cb6a8b.webp)
🔒 Securing the Edge: Introducing Secrets in Wasmer Edge
We are incredibly excited to announce a significant enhancement to Wasmer Edge: the support for secure Environment variables
![syrusakbary avatar](/_next/image?url=https%3A%2F%2Fcdn.wasmer.io%2FCACHE%2Fimages%2Favatars%2Fusers%2F1%2F39083d17bd41053e94cd835fe60f4959.png&w=64&q=75)
Syrus Akbary
Founder & CEO
July 18, 2024
![Post cover image](/_next/image?url=https%3A%2F%2Fcdn.wasmer.io%2Foriginal_images%2Fedge-secrets_3.png&w=3840&q=75)
Secure environment variables is a feature that many of you have been asking for, both in the Wasmer Community Discord and through social media. Today we are incredibly excited to announce that secret environment variables are now fully supported in Wasmer Edge.
The added support for secure environment variables allows:
- Enhanced Security: Reduces the risk of exposing sensitive data in your source code or public repositories.
- Compliance Ready: it will pave the way to comply with regulations like GDPR, HIPAA, which require strict data protection measures.
- Easy Integration: Works with your existing environment variables setup with a minimal learning curve.
How to use secrets
Using secrets in Wasmer Edge is incredibly easy.
Lets create a Javascript Worker that just returns the process.env
vars as JSON:
async function handler(request) {
const out = JSON.stringify({env: process.env});
return new Response(out, {
headers: { "content-type": "application/json" },
});
}
addEventListener("fetch", (fetchEvent) => {
fetchEvent.respondWith(handler(fetchEvent.request));
});
To create a JS Worker, you can simply run
wasmer app create --template=js-worker
and modify the contents ofsrc/index.js
. See https://secrets-worker-example.wasmer.app/ for a live example
The first time that you deploy the app (via wasmer deploy
), you will see that the app has no environment variables.
To attach new secrets to the app, you have two ways:
-
Using the Wasmer CLI:
wasmer app secrets create
$ wasmer app secrets create MY_SECRET THE_SECRET_VALUE
-
Using the app’s settings web UI (Go to your App → Settings → Secrets)
Once you create or update a secret (and redeploy the app), it will become available as an environment var of your application.
$ wasmer deploy
Et voilá!
In the future, we will integrate directly with secrets providers such as Doppler and Infisical, so your secrets can stay in sync with Wasmer Edge seamlessly.
We have created an in-depth guide in our docs, please don’t forget to give them a look! https://docs.wasmer.io/edge/learn/secrets
How secure are the Secret environment variables?
All secrets are encrypted in transit and at rest, both in the Wasmer backend and in Wasmer Edge.
Join Us on the Edge of Innovation
We welcome everyone to integrate Secret environment variables into their Wasmer Edge applications.
Try it out, and don’t hesitate to reach out with feedback or questions. Your input is invaluable as we continue to refine and enhance Wasmer Edge to meet the evolving needs of modern software development.
For more information visit Wasmer Edge documentation.
Stay secure and code on! 🔐
About the Author
Syrus Akbary is an enterpreneur and programmer. Specifically known for his contributions to the field of WebAssembly. He is the Founder and CEO of Wasmer, an innovative company that focuses on creating developer tools and infrastructure for running Wasm
![Syrus Akbary avatar](/_next/image?url=https%3A%2F%2Fcdn.wasmer.io%2FCACHE%2Fimages%2Favatars%2Fusers%2F1%2F39083d17bd41053e94cd835fe60f4959.png&w=64&q=75)
Syrus Akbary
Founder & CEO
How to use secrets
How secure are the Secret environment variables?
Join Us on the Edge of Innovation
Read more
![Post cover image](/_next/image?url=https%3A%2F%2Fcdn.wasmer.io%2Foriginal_images%2FGroup_48096081.jpg&w=3840&q=75)
wasmerwasmer edgerustprojectsedgeweb scraper
Build a Web Scraper in Rust and Deploy to Wasmer Edge
RudraAugust 14, 2023