An app writes logs, but its CloudWatch log group stays empty.
IntermediateTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer
Likely causes → The role cannot write logs (logs:CreateLogStream, logs:PutLogEvents, or logs:CreateLogGroup if the group does not exist). The log group is KMS-encrypted and the key policy does not allow the logs.<region>.amazonaws.com principal. Or you are looking in the wrong Region or group name.
Diagnose →
aws logs describe-log-groups --log-group-name-prefix /aws/lambda/orders --query 'logGroups[].[logGroupName,kmsKeyId]'
aws logs describe-log-streams --log-group-name /aws/lambda/orders --order-by LastEventTime --descending --max-items 3
aws iam list-attached-role-policies --role-name orders-lambda-role
Fix →
- For Lambda, attach
AWSLambdaBasicExecutionRole. For ECS, give the execution rolelogs:*on the group - Create the group in IaC with retention set
- Fix the KMS key policy for CloudWatch Logs
Prevent → Pre-create every log group with retention and permissions, rather than relying on auto-create, which also means infinite retention.
More on CloudFormation, CloudWatch, KMS, Secrets and Cost
Updating a stack fails: `Stack:arn:aws:cloudformation:...:stack/app/... is in ROLLBACK_COMPLETE state and can not be updated.`BeginnerA stack is stuck in `UPDATE_ROLLBACK_FAILED`.AdvancedA pipeline fails with `An error occurred (ValidationError) when calling the UpdateStack operation: No updates are to be performed.`Beginner`InsufficientCapabilitiesException: Requires capabilities : [CAPABILITY_NAMED_IAM]`.BeginnerStack deletion ends in `DELETE_FAILED` with `The bucket you tried to delete is not empty` on an S3 bucket resource.IntermediateDrift detection shows `MODIFIED` on a security group and an RDS instance that someone changed in the console. How do you reconcile?Advanced