简体   繁体   中英

How to use AWS IAM in nodejs application on fargate scheduled task

I am a student who is trying to make a scheduled task using nodejs(typescript). The task is to access S3 and fetch the object and then do some stuff with it.

However, I am having hard time trying to figure out loading the credentials. I am trying to do it without writing out the ClientConfiguration, which has the space for putting in accesskey, secretAccesskey. Hint or clue would be nice. Thank you for your time.

You can configure an IAM tole for your fargate task/service and assign permission to the role. In this way you do not have to hardcode the aws access credentials in side the code.

There are two types of IAM roles associated with ECS.

task execution role

gives permission to pull/push container images from the register and publish logs to cloudwatch.

task role

gives permission to access aws services. you should set up assign s3 permissions to this particular role.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM