{"id":16900024,"url":"https://github.com/runlevel5/netlify-plugin-ejson-env","last_synced_at":"2025-03-20T14:35:39.675Z","repository":{"id":47029747,"uuid":"407145127","full_name":"runlevel5/netlify-plugin-ejson-env","owner":"runlevel5","description":"A better way to store secret environment variables on netlify","archived":false,"fork":false,"pushed_at":"2021-09-16T16:59:35.000Z","size":632,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-26T23:20:46.587Z","etag":null,"topics":["ejson","netlify","netlify-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/runlevel5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-16T11:51:35.000Z","updated_at":"2021-09-16T22:52:35.000Z","dependencies_parsed_at":"2022-08-26T10:11:32.051Z","dependency_job_id":null,"html_url":"https://github.com/runlevel5/netlify-plugin-ejson-env","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Fnetlify-plugin-ejson-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Fnetlify-plugin-ejson-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Fnetlify-plugin-ejson-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Fnetlify-plugin-ejson-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/runlevel5","download_url":"https://codeload.github.com/runlevel5/netlify-plugin-ejson-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244166707,"owners_count":20409178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ejson","netlify","netlify-plugin"],"created_at":"2024-10-13T17:51:20.351Z","updated_at":"2025-03-20T14:35:39.655Z","avatar_url":"https://github.com/runlevel5.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# netlify-plugin-ejson-env\n\nA better way to store secret environment variables on netlify\n\n## Usage\n\nInstall [ejson](https://github.com/Shopify/ejson) then generate a key pair:\n\n```bash\n$ ejson keygen\n\nPublic Key:\n63ccf05a9492e68e12eeb1c705888aebdcc0080af7e594fc402beb24cce9d14f\nPrivate Key:\n75b80b4a693156eb435f4ed2fe397e583f461f09fd99ec2bd1bdef0a56cf6e64\n```\n\nstore the private key to environment variable:\n\n```bash\n$ export EJSON_PRIVATE_KEY=\"75b80b4a693156eb435f4ed2fe397e583f461f09fd99ec2bd1bdef0a56cf6e64\"\n```\n\nplease make sure you store this private key in somewhere safe. Please don't lose\nit!!\n\nthen create the `secrets.ejson` file in your project root folder:\n\n```json\n{\n  \"_public_key\": \"63ccf05a9492e68e12eeb1c705888aebdcc0080af7e594fc402beb24cce9d14f\",\n  \"environment\": {\n    \"SECRET_VAR1\": \"secret_in_plaintext\"\n  }\n}\n```\n\nand then encrypt our secrets:\n\n```\n$ ejson encrypt secrets.ejson\n```\n\nthe `SECRET_VAR1` should now have encrypted value, verify that easily with:\n\n```\n$ cat secrets.ejson\n\n# stripped output\n\"SECRET_VAR1\": \"EJ[1:3eCI5YRF+jVXBa3I39lOjuM41HwX3k3dedBVMIIWyUk=:cobOAF#@(*\u0026VLKJL#@\"\n```\n\nand let's try to decrypt our secrets:\n\n```\n$ echo $EJSON_PRIVATE_KEY | ejson decrypt --key-from-stdin secrets.ejson\n\n{\n  \"_public_key\": \"63ccf05a9492e68e12eeb1c705888aebdcc0080af7e594fc402beb24cce9d14f\",\n  \"environment\": {\n    \"SECRET_VAR1\": \"secret_in_plaintext\"\n  }\n}\n```\n\nNext, please create a new environment variable in Netlify build settings:\n\n```\nEJSON_PRIVATE_KEY: \"75b80b4a693156eb435f4ed2fe397e583f461f09fd99ec2bd1bdef0a56cf6e64\"\n```\n\n![Build environment](./screenshot1.png)\n\nLet's move on to install the plugin in the Netlify UI, use this\n[direct in-app installation link](https://app.netlify.com/plugins/netlify-plugin-ejson-env/install)\nor go to the [Plugins directory](https://app.netlify.com/plugins).\n\nFor file-based installation, add the following lines to your `netlify.toml`\nfile:\n\n```toml\n[[plugins]]\npackage = \"@runlevel5/netlify-plugin-ejson-env\"\n\n  # all inputs are optional, we just show you the defaults below\n  [plugins.inputs]\n\n  ejsonPrivateKeyEnvVarName = \"EJSON_PRIVATE_KEY\" # the environment variable name that contains the EJSON private key as value\n  ejsonSecretsFilePath = \"./secrets.ejson\" # the EJSON file that contains encrypted key-value pairs\n```\n\nTo complete file-based installation, from your project's base directory, use\nnpm, yarn, or any other Node.js package manager to add the plugin to\n`devDependencies` in `package.json`.\n\n```bash\nnpm install -D @runlevel5/netlify-plugin-ejson-env\n```\n\n### Execution in Netlify\n\nOnce installed and configured, the plugin will automatically run in the Netlify\nCI during its specified Netlify Build lifecycle event and all key-value pairs in\nthe secrets EJSON file would be populated as environment variables.\n\n### Executing locally\n\nTo test the execution of the Netlify Build lifecycle locally, first ensure that\nnetlify-build is installed:\n\n```bash\n# Ensure that you have the netlify build command available\n# (in future this will be provided via the CLI)\nnpm install @netlify/build -g\n```\n\nand [direnv](http://direnv.net) is installed:\n\n```\ncp .envrc.example .envrc\ndirenv allow\n```\n\nthen in the project working directory, run the build as netlify would with the\nbuild bot:\n\n```\nnetlify-build\n```\n\n## Credits\n\n- I borrow lots of the structure for this repo from\n  [netlify-plugin-a11y](https://github.com/netlify-labs/netlify-plugin-a11y)\n- Thanks to Shopify for the [ejson](https://github.com/Shopify/ejson)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunlevel5%2Fnetlify-plugin-ejson-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frunlevel5%2Fnetlify-plugin-ejson-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunlevel5%2Fnetlify-plugin-ejson-env/lists"}