<p>I am working on a .net 6.0 application that will run in an EKS cluster, but I am developing using Docker Desktop and Kubernetes. Whilst I can pass in the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc via the Helm Chart as Environment variables the issue I am facing is that I keep seeing <strong>The security token included in the request is expired</strong>, I can update the values and redeploy but clearly that is a pain to do.</p>
<p>When this is running in EKS it will use IAM Roles etc so isn't an issue but just wondered if anyone has a solution for doing this locally. If I run up the code in VS rather than Docker it picks up the credentials from the aws credentials file and runs (even though I haven't updated the token).</p>
<p><a href="https://i.stack.imgur.com/E5eXD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E5eXD.png" alt="enter image description here" /></a></p>
<p>In the code snippet above the environment var is set to <strong>local</strong> when running in my Docker Desktop Kubernetes.</p>
<p>Any ideas if there is a solution for this?</p>

simongking
<p>I have solved this eventually, I was working on other aspects of the project so have only just come back to the problem.</p>
<p>As I am deploying with a helm chart I needed to setup the volume in the deployment mapping the volume requires the path of the folder to be prefixed with:</p>
<p>/run/desktop/mnt/host/</p>
<p>so the yaml will looks something like this:</p>
<pre><code>volumes:
   - name: dev-aws-creds
     hostPath:
        path: /run/desktop/mnt/host/c/Users/simon/.aws/
        type: Directory

volumeMounts:
   - name: dev-aws-creds
     mountPath: /.aws/
</code></pre>
<p>Note the volume is not read only it seems that the AWS code writes back a value to the file. As suggested I needed to provide the desired profile in the AWS_PROFILE environment and also you can specify the credentials folder with the env var AWS_SHARED_CREDENTIALS_FILE.</p>
<p>Also if your profile has any sso values it doesn't seem to work so it makes sense to have a profile that specifically is for your containers like the following.</p>
<pre><code>[docker]
aws_access_key_id=&lt;access_key_id&gt;
aws_secret_access_key=&lt;secret_access_key&gt;
aws_session_token=&lt;session_token&gt;
</code></pre>
<p>I still need to refresh these when the values expire but it means that I only need to do it in one place rather than modify environment variables in each helm chart.</p>
