<p>I am trying to apply kubernetes code that was given for me. I am getting an error:</p>
<pre><code>Error from server (BadRequest): error when creating &quot;infra/ecr-creds/rendered.yml&quot;: Secret in version &quot;v1&quot; cannot be handled as a Secret: illegal base64 data at input byte 0
</code></pre>
<p>From what I understand, the error is coming from this:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: aws-ecr-creds-secret
  namespace: whatever
  labels:
    app.kubernetes.io/name: aws-multi-ecr-credentials
    helm.sh/chart: aws-multi-ecr-credentials-1.4.3
    app.kubernetes.io/instance: aws-ecr-creds-novisign
    app.kubernetes.io/version: &quot;1.4.3&quot;
    app.kubernetes.io/managed-by: Helm
type: Opaque
data:
  AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
  AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
</code></pre>
<p>I tried to set the <code>AWS_ACCESS_KEY_ID</code> variable using:</p>
<pre><code>export AWS_ACCESS_KEY_ID=$(echo &quot;...code...&quot; | base64)
</code></pre>
<p>but it doesn't work. What is the proper way to do it?</p>

<p>You should use <code>stringData</code>:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: aws-ecr-creds-secret
  namespace: whatever
  labels:
    app.kubernetes.io/name: aws-multi-ecr-credentials
    helm.sh/chart: aws-multi-ecr-credentials-1.4.3
    app.kubernetes.io/instance: aws-ecr-creds-novisign
    app.kubernetes.io/version: &quot;1.4.3&quot;
    app.kubernetes.io/managed-by: Helm
type: Opaque
stringData:
  AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
  AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
</code></pre>
<p>Link references:<br />
<a href="https://hub.docker.com/repository/docker/cuongquocvn/aws-cli-kubectl" rel="nofollow noreferrer">https://hub.docker.com/repository/docker/cuongquocvn/aws-cli-kubectl</a></p>
