I am facing an issue with AWS S3 upload.

xuanbao · · 403 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>My Go binary is deployed using docker. In my docker image I have set env variables like : ENV AWS_ACCESS_KEY_ID = &lt;MYKEY&gt; ENV AWS_SECRET_ACCESS_KEY = &lt;MYKEY&gt;</p> <p>I build the image and run the container using docker run -d -p &lt;imageid&gt;.</p> <p>Now the problem is when I try to do an s3 upload. I get an error : AuthorizationHeaderMalformed</p> <p>But when I pass the env variables in docker run command like docker run -d -e AWS_KEY=12312 -e AWS_SECRET_KEY=222</p> <p>everything work perfectly fine. What might be the issue here ? Please help.</p> <hr/>**评论:**<br/><br/>fiskeben: <pre><p>How do you build your image? Try running <code>docker inspect &lt;containerID&gt;</code> to see if the variables are set and have the correct values.</p> <p>It sounds like you&#39;re hardcoding the variables in the Dockerfile, don&#39;t do that. It&#39;s very insecure. You could just as well make the bucket public.</p> <p>Passing the keys as command line parameters is slightly better and should be preferred over putting them in the Dockerfile.</p></pre>razor_XI: <pre><p>Thanks for your suggestion. At the moment, I have resolved the issue by passing the env variables in the command line.</p></pre>victrolla: <pre><p>I think The reason is your environment variables are missing underscores after AWS.</p></pre>razor_XI: <pre><p>I do have underscores, I have also pasted the entire ENV variable command in the description. At the moment I have resolved the issue by passing the env as a command line argument.</p></pre>victrolla: <pre><p>In that case are you wrapping the env car in quotes? Perhaps you’re not trimming the quotes which would cause this error as the access key is a part of the s3 signed header. </p></pre>drcloudycoder: <pre><p>Do you have the correct region of the bucket set? Sometimes I have seen that explicitly passing/setting the S3 bucket&#39;s region in your S3 calls help.</p></pre>razor_XI: <pre><p>Yes, I have set the correct region. I think the problem is with setting the env variables which I need to look into.</p></pre>absdevops: <pre><p>In Dockerfile syntax its like this:</p> <p><code>ENV AWS_ACCESS_KEY_ID &lt;MYKEY&gt;</code></p> <p>^ There is no &#34;=&#34; supposed to be there</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

403 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传