How to give access via role to Fargate container from AWS BATCH jobs interface

0

I have a docker image based on awslinux:latest with nodejs that I want to run in AWS Batch. The Job role configuration has Admin privilege for testing purposes. When I create a job and pass my AWS ID and AWS SECRET as env variables, everything works fine. But if I do not pass them the task just breaks, and node does not have access to AWS services. I assume that the permissions should be coming from the Job role but for some reason it doesn't work.

AWS SDK node version 2.1043.0

Log output Log output

已提問 1 年前檢視次數 451 次
1 個回答
0

To give access to Fargate containers from AWS Batch jobs interface, you can create an IAM Role that grants the necessary permissions to access the AWS services that your application requires, such as S3 or DynamoDB. You can then specify this role in your job definition when you submit a job to AWS Batch.

To do this, follow these steps:

  1. Create an IAM role with the necessary permissions for your application to access AWS services. You can use the AWS Management Console, AWS CLI, or AWS SDKs to create the role. Make sure to grant the appropriate permissions to access the services you need, and attach the role to the ECS task execution role.
  2. Create an AWS Batch job definition that specifies the container image, environment variables, and any other configuration options for your Fargate container.
  3. In the job definition, specify the IAM role you created in step 1 using the executionRoleArn parameter. This will grant the Fargate container the necessary permissions to access AWS services.
  4. Submit a job to AWS Batch using the job definition you created in step 2. The job will run with the permissions granted by the IAM role specified in the job definition.

By following these steps, you should be able to give access via role to Fargate container from AWS Batch jobs interface, without needing to pass your AWS ID and AWS SECRET as environment variables.

profile picture
Yasser
已回答 1 年前
  • @Yasser That was my point I gave both roles (execution and job role) even admin privillage and I till get the above error unless I pass the env. So the role maybe is not loaded properly in the docker container

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

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

回答問題指南