Interview Prep/AWS/Observability, Secrets, KMS and CloudFormation

How do you centralize application logs from many EC2 and ECS services?

BeginnerScenarioObservability, Secrets, KMS and CloudFormation
Answer

Situation read → CloudWatch Logs with agents or log drivers, then subscription filters.

What I'd do →

  1. EC2 uses the CloudWatch agent with amazon-cloudwatch-agent-ctl -a fetch-config
  2. ECS uses the awslogs driver
  3. Set retention: aws logs put-retention-policy --log-group-name /app/api --retention-in-days 30
  4. Subscription filter to Kinesis Firehose to S3 for archive
  5. Query with Logs Insights

Why → Retention defaults to never expire, which is a silent cost.

Interview tip → Always set retention.

aws All AWS questions

More on Observability, Secrets, KMS and CloudFormation