how to upload files to s3 without using Access key from EC2 through React Js

0

I want to upload the files to s3 without using access key from EC2 through react js , how can i do this using IAM or suggest me best practice to do that without exposing credentials

2 回答
0

Hello.

If the execution environment is EC2, you can access S3 using an IAM role.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#working-with-iam-roles

profile picture
专家
已回答 3 个月前
  • i have attach IAM role to AWS which provide access to S3 ,kindly suggest me sdk or sample to code to upload files directly to S3

0

Hi. We can also use IMDS v2 on EC2 to get credential.
https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html

<Example commend>.

  1. to get token.
    TOKEN= 'curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds:21600"'

  2. to get credential from IAM role.
    curl -H "X-aws-ec2-metadata-token:$TOKEN" -v http://169.254.169.254/latest/meta-data/iam/security-credentials/<IAM-role>

But IMDS2 looks like it does not support recat js.
https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/use-a-supported-sdk-version-for-imdsv2.html

AWS
已回答 3 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容