<p>In EKS I am trying to use SecretProviderClass to provide secrets as environment variables to containers. I can see the secret mounted inside the container but no combination of key/names is allowing me to use it as an environment variable. Insode the container I can
<code>cat /mnt/secrets-store/awscredentials</code>
And see the output:</p>
<pre><code>{&quot;accesskey&quot;:&quot;ABCDE12345&quot;,&quot;secretkey&quot;:&quot;a/long/redacted5tring&quot;}
</code></pre>
<p>My SecretProviderClass is below</p>
<pre><code>apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: aws-secrets
  namespace: default
spec:
  provider: aws
  parameters:
    objects: |
        - objectName: &quot;path/to/service/awscredentials&quot;
          objectType: secretsmanager
          objectAlias: awscredentials
  secretObjects:
  - secretName: awscredentials
    type: Opaque
    data: 
    - objectName: accesskeyalias
      key: accesskey
    - objectName: secretkeyalias
      key: secretkey

</code></pre>
<p>and my deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: myservice
  labels:
    team: devops
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myservice
  template:
    metadata:
      labels:
        app: myservice
    spec:
      serviceAccountName: myservice
      volumes:
      - name: secrets-store-inline
        csi:
          driver: secrets-store.csi.k8s.io
          readOnly: true
          volumeAttributes:
            secretProviderClass: &quot;aws-secrets&quot;
      containers:
      - name: myservice
        image: someimage:2
        volumeMounts:
        - name: secrets-store-inline
          mountPath: &quot;/mnt/secrets-store&quot;
          readOnly: true
        env:
        - name: AWS_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              name: awscredentials
              key: accesskey
</code></pre>
<p>When I run the deployment without reference to the SecretKeyRef the container runs and I can see the secret under <code>/mnt/secrets-store/awscredentials</code>. However, trying to set the environment variable results in the pod stuck in Pending state and the message:
<code>Error: secret &quot;awscredentials&quot; not found</code>
I reckon I have mixed up the name and keys somewhere but I've spent hours trying every combination I can think of. What am I missing?</p>

<p>I eventually got this sorted. I had followed the AWS documentation for installing the driver which included using a helm chart i.e.</p>
<pre><code>helm install -n kube-system csi-secrets-store secrets-store-csi-driver/secrets-store-csi-driver
</code></pre>
<p>However, the documentation failed to point out that with this helm chart you need to specifically set a value <code>syncSecret.enabled=true</code> - as in the code below.</p>
<pre><code>helm install -n kube-system csi-secrets-store secrets-store-csi-driver/secrets-store-csi-driver --set syncSecret.enabled=true
</code></pre>
<p>I used helm to uninstall the secrets-store-csi-driver, then re-installed with <code>syncSecret.enabled=true</code> and immediately my secretsmanager secret was available via <code>kubectl get secrets -n default</code>.
So if you can see the secrets inside the container in the mounted volume but you can't set them as environment variables you should check that you installed with this value so that the k8s secret is created. Otherwise the   secretObjects &gt; secretName section is not actioned.</p>
