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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南