Amazon ECS distinguishes between two key IAM roles assigned to tasks:
ecsTaskExecutionRole): Utilized by the Amazon ECS container agent and Fargate infrastructure to pull private container images from Amazon ECR and send system logs to Amazon CloudWatch Logs.ECSTaskFullAccessToS3Role): Assumed directly by the application and sidecar containers running inside the task. When AWS FireLens is configured, the Fluent Bit sidecar container requires AWS credentials provided by the task role to perform s3:PutObject API operations against your Amazon S3 bucket.Log in to the AWS Management Console.
In the top search bar, enter IAM
Under the Services category, click IAM (Manage access to AWS resources)

In the left navigation pane under Access Management, click Roles
On the Roles dashboard, click the orange Create role button

On the Select trusted entity page, configure the principal authority:
In the Use case section:
Click the orange Next button.

On the Add permissions page, search for the Amazon S3 managed policy:
AmazonS3FullAccessIn the filtered policy results table:
Click the orange Next button

While attaching AmazonS3FullAccess accelerates lab setup, production security standards require applying least privilege. For an enterprise deployment, author a customer-managed IAM policy restricted exclusively to actions like s3:PutObject and s3:PutObjectAcl, scoped directly to the target bucket ARN: arn:aws:s3:::firelens-logs-7180/*.
On the Name, review, and create page, enter the role metadata:
ECSTaskFullAccessToS3RoleAllows ECS tasks to call AWS services on your behalf.Scroll to the bottom of the page and click the orange Create role button.

