Search code examples
amazon-web-servicesamazon-ecsaws-iot-coreaws-credentials

AWS Credential Provider for ECS task


I want to use auth.AwsCredentialsProvider.new_default_chain() method in ECS task. In API doc https://awslabs.github.io/aws-crt-python/api/auth.html#awscrt.auth.AwsCredentialsProvider, found following:

Create the default provider chain used by most AWS SDKs.

Generally:

  1. Environment
  2. Profile
  3. (conditional, off by default) ECS
  4. (conditional, on by default) EC2 Instance Metadata

What does (conditional, off by default) mean and how to turn it on?


Solution

  • To enable it, you have to create an IAM Role for your ECS task, and attach it in the task definition for Amazon Elastic Container Service (Amazon ECS).

    Task IAM role - Your Amazon ECS tasks can have an IAM role associated with them. The permissions granted in the IAM role are assumed by the containers running in the task. See Task IAM role

    Below is the place (highlighted) where you can specify IAM Role while creating the Task Definition.

    enter image description here