<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Josh Dvir</title>
    <description>The latest articles on Forem by Josh Dvir (@joshdvir).</description>
    <link>https://forem.com/joshdvir</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F190610%2F10facd32-ee1d-4883-b581-0e71381e05d9.jpeg</url>
      <title>Forem: Josh Dvir</title>
      <link>https://forem.com/joshdvir</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/joshdvir"/>
    <language>en</language>
    <item>
      <title>Provide environment variables to your applications in a secure way</title>
      <dc:creator>Josh Dvir</dc:creator>
      <pubDate>Fri, 10 Jan 2020 18:51:45 +0000</pubDate>
      <link>https://forem.com/joshdvir/provide-environment-variables-to-your-applications-in-a-secure-way-4f33</link>
      <guid>https://forem.com/joshdvir/provide-environment-variables-to-your-applications-in-a-secure-way-4f33</guid>
      <description>&lt;p&gt;These days even the smallest of startups have multiple applications (microservices), each application has its own needs, but common to all applications is they all have secrets they need to function correctly.&lt;br&gt;
To all my clients, I recommend using &lt;a href="https://www.vaultproject.io/"&gt;Vault&lt;/a&gt; by Hashicorp to keep their secrets safe.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Vault?
&lt;/h3&gt;

&lt;p&gt;"Secure, store, and tightly control access to tokens, passwords, certificates, encryption keys for protecting secrets and other sensitive data using a UI, CLI, or HTTP API." &lt;a href="https://www.vaultproject.io/"&gt;(from their website)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do people sometimes need convincing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most of the responses I get trying to implement such a service are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We do not need such a service&lt;/li&gt;
&lt;li&gt;It will take too much time to apply, and it's time we don't have.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;To help our clients implement the solution in a secure, quick way, we created a small Golang application that connects to Vault and pulls the secrets exposing them as environment variables.&lt;/p&gt;

&lt;p&gt;I know it sounds simple; it is!&lt;/p&gt;

&lt;p&gt;The application is &lt;a href="https://github.com/devops-israel/vault-get"&gt;vault-get&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use &lt;a href="https://github.com/devops-israel/vault-get"&gt;vault-get&lt;/a&gt;:
&lt;/h3&gt;

&lt;p&gt;All our applications are Docker-based so when we create the Docker image we install &lt;a href="https://github.com/devops-israel/vault-get"&gt;vault-get&lt;/a&gt; into the container for use:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM SomeBaseImage
ADD https://github.com/devops-israel/vault-get/releases/download/v1.0.0/vault-get-linux-amd64 /usr/bin/vault-get-linux-amd64
RUN chmod +x /usr/bin/vault-get-linux-amd64 \
    &amp;amp;&amp;amp; mv /usr/bin/vault-get-linux-amd64 /usr/bin/vault-get
WORKDIR /app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;Add&lt;/code&gt;ing the executable is downloading it and give it the right permissions.&lt;/p&gt;

&lt;p&gt;Then all you need to do is expose the configuration and &lt;a href="https://github.com/devops-israel/vault-get"&gt;vault-get&lt;/a&gt; will fetch the secret and expose them as environment variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage Examples
&lt;/h3&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Using a token auth (--vault_auth token does not need to be set explicitly):
eval "$(vault-get --vault_host https://vault.example.com --vault_token mytoken --vault_path secret/my-secret)"

# Doing the same with a user and password authentication:
eval "$(vault-get --vault_host https://vault.example.com --vault_auth userpass --vault_username user --vault_password pass --vault_path secret/my-secret)"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/devops-israel/vault-get"&gt;vault-get&lt;/a&gt; has been in production for over 6 months and it helps us provide secure secret injection from Vault to our applications without any need to interact with the application, the app itself gets the environment variables it needs, it's just not aware of the provider 😉&lt;/p&gt;

&lt;p&gt;A significant benefit we got from moving to Vault was the fact that the Devops team is not a bottleneck anymore, now developers can add the secrets their applications need by themselves, we'll talk about permissions on another post.&lt;/p&gt;

&lt;p&gt;Either you need a tool like &lt;a href="https://github.com/devops-israel/vault-get"&gt;vault-get&lt;/a&gt; or not, securing your secrets is the best practice you can take.&lt;/p&gt;

&lt;p&gt;Good Luck!&lt;/p&gt;

</description>
      <category>vault</category>
      <category>docker</category>
      <category>security</category>
      <category>go</category>
    </item>
  </channel>
</rss>
