@@ -172,8 +172,9 @@ export class BackendStack extends cdk.Stack {
172172 } ) ,
173173 } ) ;
174174
175- const table = new Table ( scope , id , {
176- tableName : `${ appName } ReportsTable` ,
175+ // Create DynamoDB table for reports
176+ const reportsTable = new Table ( this , `${ appName } ReportsTable` , {
177+ tableName : `${ appName } ReportsTable${ props . environment } ` ,
177178 partitionKey : {
178179 name : 'userId' ,
179180 type : AttributeType . STRING ,
@@ -183,11 +184,11 @@ export class BackendStack extends cdk.Stack {
183184 type : AttributeType . STRING ,
184185 } ,
185186 billingMode : BillingMode . PAY_PER_REQUEST ,
186- removalPolicy : RemovalPolicy . RETAIN ,
187+ removalPolicy : isProd ? RemovalPolicy . RETAIN : RemovalPolicy . DESTROY ,
187188 } ) ;
188189
189190 // Add a GSI for querying by date (most recent first)
190- table . addGlobalSecondaryIndex ( {
191+ reportsTable . addGlobalSecondaryIndex ( {
191192 indexName : 'userIdDateIndex' ,
192193 partitionKey : {
193194 name : 'userId' ,
@@ -199,6 +200,12 @@ export class BackendStack extends cdk.Stack {
199200 } ,
200201 } ) ;
201202
203+ // Add output for the table name
204+ new cdk . CfnOutput ( this , 'ReportsTableName' , {
205+ value : reportsTable . tableName ,
206+ description : 'DynamoDB Reports Table Name' ,
207+ } ) ;
208+
202209 // Add output for Cognito domain
203210 new cdk . CfnOutput ( this , 'CognitoDomain' , {
204211 value : `https://${ userPoolDomain . domainName } .auth.${ this . region } .amazoncognito.com` ,
0 commit comments