Attach task-execution role to task definition in Elastic Container Service
Step 1: Create the S3 Bucket
Go to the Amazon S3 console.
Click on "Create bucket".
Enter a unique name for your bucket, for example, cmis-bucket.
Choose the region for your bucket.
Click "Next".
Click "Next" and then "Create bucket".
Step 2: Create the IAM Role (ecs-task-role)
Go to the AWS Management Console and navigate to the IAM service.
Click on "Roles" in the left-hand menu.
Click on "Create role".
Choose "AWS service" as the type of trusted entity.
Select "Elastic Container Service (ECS)" as the service that will use this role.
Click "Next: Permissions".
Search for and select the appropriate S3 permissions you want to grant to your ECS tasks. For example, you might choose AmazonS3FullAccess if you want read-only access to S3.
Give your role a name, for example, ecs-task-role, and optionally provide a description.
Click "Create role".
Step 3: Create an ECS Cluster
Go to the Amazon ECS console.
Click on "Clusters" in the left-hand menu.
Click on "Create Cluster".
Provide a name for your cluster, for example cluster1.
Click "Create".
Step 4: Create a Task Definition with the IAM Role
Go to the Amazon ECS console.
Click on "Task Definitions" in the left-hand menu.
Click on "Create new Task Definition".
Choose a launch type compatibility Fargate.
Configure your container settings (image, CPU, memory, etc.).
Under "Task role", select the previously create role.
Configure the rest of your task definition as needed.
Click "Create".
Step 5: Run Your Task on ECS Cluster
Go to the Amazon ECS console.
Click on "Clusters" in the left-hand menu and select your cluster (cluster1).
Click on the "Tasks" tab and then click "Run new Task".
Select your task definition and click "Run Task".
Follow the prompts to configure your task settings and run your task.
Now your ECS task will have the IAM role (ecs-task-role) assigned to it, which grants access to Amazon S3.