Update ECS Service

AWS FireLens enables Amazon ECS to route container logs directly to storage systems and analytics tools without modifying application code. By enabling FireLens, Amazon ECS injects an AWS for Fluent Bit sidecar container into your task definition. Application container standard output (stdout) and standard error (stderr) streams are automatically routed to the Fluent Bit sidecar container via a local socket using the Fluentd forward protocol. Fluent Bit then buffers the log events, compresses them, and writes them to your Amazon S3 bucket.


Step 1: Select the frontend task definition

  1. Open the Amazon Elastic Container Service console.

  2. In the left navigation menu, click Task definitions.

  3. In the task definitions list, click FCAJResbar-task-fe.

    Select task definition FCAJResbar-task-fe


Step 2: Create a new task definition revision

  1. Click the Create new revision split button and select Create new revision

    Create new task definition revision


Step 3: Assign the IAM task role

  1. On the Create revision page, locate the Task roles - conditional section:

    • In the Task role dropdown menu, select ECSTaskFullAccessToS3Role (the role created in module 7.2).
    • Verify that Task execution role remains set to ecsTaskExecutionRole.

    Assign task role ECSTaskFullAccessToS3Role

Setting the Task role grants the running Fluent Bit sidecar container temporary AWS STS credentials required to upload log objects directly into your Amazon S3 bucket via the AWS SDK.


Step 4: Configure FireLens log collection on the application container

  1. Scroll down to the Container - 1 section (representing the application container named frontend).

  2. Expand the Log collection panel:

    • Ensure the checkbox Use log collection is checked.
    • In the Destination dropdown menu, select Export logs to S3 via AWS FireLens.

    Configure log collection destination


Step 5: Specify S3 bucket destination and retry limit

  1. In the log collection key-value options table:
    • Locate the row where Key is bucket: in the Value field, enter firelens-logs-7180
  2. Below the options table, click the Add log configuration option button.
  3. In the newly generated row:
    • In the Key field: enter retry_limit
    • In the Value field: enter 2 Configure S3 bucket name and retry limit

Step 6: Configure the FireLens sidecar container

  1. Scroll down to the second container automatically injected by the console:

    • Name: log_router
    • Essential container: Ensure Yes is selected.
    • Image URI: Confirm that the image URI is set to public.ecr.aws/aws-observability/aws-for-fluent-bit:stable
  2. Under Resource allocation limits - conditional

    • In the CPU field: enter 1 (1 vCPU).
    • In the Memory hard limit field: enter 3 (3 GB).
    • In the Memory soft limit field: enter 2 (2 GB).

    Configure FireLens log router container


Step 7: Create the task definition revision

  1. In the lower-right corner, click the orange Create button.

    Submit task definition creation


Step 8: Verify revision creation

  1. Verify that the console displays the green success banner: Verify task definition revision overview

Step 9: Initiate service update

  1. Click the Deploy dropdown button and select Update service.

    Deploy dropdown update service


Step 10: Configure deployment revision

  1. On the Update service page, locate the Deployment configuration section:

    • In the Task definition revision field, select the latest revision.

    Select revision 12 in deployment configuration


Step 11: Apply the service update

  1. Click the orange Update button.

    Submit service update


Step 12: Verify deployment completion

  1. In the Amazon ECS console, navigate to Clusters > FCAJ-Lab-cluster > Services > app-frontend > Deployments.

  2. Monitor the Latest service deployment timeline:

    Verify service rolling deployment success