<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can secrets be retrieved only for the scope of an init script? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24485#M17023</link>
    <description>&lt;P&gt;@Fermin Vicente​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi vicente,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the below in your init script which will remove the environment variables from the spark-env.sh so that it will not be available after running the init script:&lt;/P&gt;&lt;P&gt;sed -i '/^TOKEN/d' /databricks/spark/conf/spark-env.sh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;if you have set the below environment variable in cluster spark environment variable:&lt;/P&gt;&lt;P&gt;TOKEN={{secrets/mlflow_model_reg/ml-token}}&lt;/P&gt;&lt;P&gt;in your init script use the below line at last which will remove the "TOKEN" environment variable from the spark env:&lt;/P&gt;&lt;P&gt;sed -i '/^TOKEN/d' /databricks/spark/conf/spark-env.sh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Mar 2022 08:32:54 GMT</pubDate>
    <dc:creator>pavan_kumar</dc:creator>
    <dc:date>2022-03-29T08:32:54Z</dc:date>
    <item>
      <title>Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24480#M17018</link>
      <description>&lt;P&gt;Hi there, if I set any secret in an env var to be used by a cluster-scoped init script, it remains available for the users attaching any notebook to the cluster and easily extracted with a print.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's some hint &lt;A href="https://docs.databricks.com/security/secrets/secrets.html#store-the-path-to-a-secret-in-an-environment-variable" alt="https://docs.databricks.com/security/secrets/secrets.html#store-the-path-to-a-secret-in-an-environment-variable" target="_blank"&gt;&lt;U&gt;in the documentation&lt;/U&gt;&lt;/A&gt; about the secret being "&lt;I&gt;not accessible&lt;/I&gt;&amp;nbsp;from a program running in Spark" (I assume it refers to commands ran in notebooks as well) but I tried several combinations to no avail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Specifying the secret path with the standard "{{secrets/scope_name/secret_name}}" works, but the secret is accessible from any notebook afterwards&lt;/LI&gt;&lt;LI&gt;The substitution by the actual secret value doesn't work in init script or notebook if I use a path without {{ }} or the &lt;I&gt;secrets/&lt;/I&gt; part. I tried because the &lt;A href="https://docs.databricks.com/security/secrets/secrets.html#store-the-path-to-a-secret-in-an-environment-variable" alt="https://docs.databricks.com/security/secrets/secrets.html#store-the-path-to-a-secret-in-an-environment-variable" target="_blank"&gt;&lt;U&gt;SPARKPASSWORD documentation&lt;/U&gt;&lt;/A&gt; could be interpreted that way&lt;/LI&gt;&lt;LI&gt;Using an env var named 'SPARKPASSWORD' seems to behave no different to any other env var naming&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure I'm missing something. Any help would be appreciated, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 14:55:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24480#M17018</guid>
      <dc:creator>fermin_vicente</dc:creator>
      <dc:date>2022-03-28T14:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24481#M17019</link>
      <description>&lt;P&gt;spark.password {{secrets/scope1/key1}} is spark property and than it will be available in all notebooks via spark.conf.get("spark.password") (we add in Spark config for cluster)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPARKPASSWORD={{secrets/scope1/key1}} is environment variable (we add it in Environment variables in cluster config)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that with a standard account you have access to secrets anyway - all of them. In premium, you could make different scopes and set one of them to be accessible only to users who create.start cluster (environment variable) so then people running notebooks will have no access to that secrets.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:07:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24481#M17019</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-03-28T16:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24482#M17020</link>
      <description>&lt;P&gt;Thanks. We do have premium and we use scopes, but we want users to not be able to print the secret within the environment variable with a simple Python command&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;' '.join(os.environ['SPARKPASSWORD'])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 07:19:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24482#M17020</guid>
      <dc:creator>fermin_vicente</dc:creator>
      <dc:date>2022-03-29T07:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24483#M17021</link>
      <description>&lt;P&gt;@Fermin Vicente​&amp;nbsp; usually when any user tries to print the values from the secrets it will be redacted. can you please try to print and check if you are seeing the actual value?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 07:37:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24483#M17021</guid>
      <dc:creator>pavan_kumar</dc:creator>
      <dc:date>2022-03-29T07:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24484#M17022</link>
      <description>&lt;P&gt;Hi Pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;print(os.environ['SPARKPASSWORD'])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the output is [REDACTED]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;however, if you run the command I put in my previous reply (and it's just one of many ways to do it), you can perfectly see the contents of the secret.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to make the env var unset after running the init script? &lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 07:43:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24484#M17022</guid>
      <dc:creator>fermin_vicente</dc:creator>
      <dc:date>2022-03-29T07:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24485#M17023</link>
      <description>&lt;P&gt;@Fermin Vicente​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi vicente,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the below in your init script which will remove the environment variables from the spark-env.sh so that it will not be available after running the init script:&lt;/P&gt;&lt;P&gt;sed -i '/^TOKEN/d' /databricks/spark/conf/spark-env.sh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;if you have set the below environment variable in cluster spark environment variable:&lt;/P&gt;&lt;P&gt;TOKEN={{secrets/mlflow_model_reg/ml-token}}&lt;/P&gt;&lt;P&gt;in your init script use the below line at last which will remove the "TOKEN" environment variable from the spark env:&lt;/P&gt;&lt;P&gt;sed -i '/^TOKEN/d' /databricks/spark/conf/spark-env.sh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 08:32:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24485#M17023</guid>
      <dc:creator>pavan_kumar</dc:creator>
      <dc:date>2022-03-29T08:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24486#M17024</link>
      <description>&lt;P&gt;Thanks a lot Pavan, that approach works like a charm!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 11:11:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24486#M17024</guid>
      <dc:creator>fermin_vicente</dc:creator>
      <dc:date>2022-03-29T11:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can secrets be retrieved only for the scope of an init script?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24487#M17025</link>
      <description>&lt;P&gt;@Fermin Vicente​&amp;nbsp;&lt;/P&gt;&lt;P&gt;good to know that this approach is working well. but please make sure that you use this approach at the end of your init script only&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 11:13:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-secrets-be-retrieved-only-for-the-scope-of-an-init-script/m-p/24487#M17025</guid>
      <dc:creator>pavan_kumar</dc:creator>
      <dc:date>2022-03-29T11:13:48Z</dc:date>
    </item>
  </channel>
</rss>

