@@ -2,6 +2,7 @@ import * as cdk from 'aws-cdk-lib/core';
22import * as dynamodb from 'aws-cdk-lib/aws-dynamodb' ;
33import * as appsync from 'aws-cdk-lib/aws-appsync' ;
44import * as lambda from 'aws-cdk-lib/aws-lambda' ;
5+ import * as logs from 'aws-cdk-lib/aws-logs' ;
56import * as route53 from 'aws-cdk-lib/aws-route53' ;
67import * as acm from 'aws-cdk-lib/aws-certificatemanager' ;
78import * as targets from 'aws-cdk-lib/aws-route53-targets' ;
@@ -143,8 +144,17 @@ export class MeshV2Stack extends cdk.Stack {
143144
144145 xrayEnabled : stage !== 'prod' ,
145146 logConfig : {
146- fieldLogLevel : stage === 'prod' ? appsync . FieldLogLevel . ERROR : appsync . FieldLogLevel . ALL ,
147- excludeVerboseContent : stage === 'prod' ,
147+ // stg was ALL + verbose, which grows the CloudWatch log group fast
148+ // (blew the free tier). Only escalate to ALL when explicitly debugging
149+ // via MESH_VERBOSE_LOGS=1; otherwise ERROR + exclude verbose on every
150+ // stage.
151+ fieldLogLevel : process . env . MESH_VERBOSE_LOGS === '1'
152+ ? appsync . FieldLogLevel . ALL
153+ : appsync . FieldLogLevel . ERROR ,
154+ excludeVerboseContent : process . env . MESH_VERBOSE_LOGS !== '1' ,
155+ // Cap retention so the AppSync-managed log group cannot accumulate
156+ // forever (the prod group had reached ~7.8GB with no expiry).
157+ retention : logs . RetentionDays . ONE_MONTH ,
148158 } ,
149159 } ) ;
150160
0 commit comments