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 Antworten
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
EXPERTE
beantwortet vor 3 Monaten
  • 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
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen