@@ -4,13 +4,15 @@ import { GuAlarm } from '@guardian/cdk/lib/constructs/cloudwatch';
44import type { GuStackProps } from '@guardian/cdk/lib/constructs/core' ;
55import { GuStack } from '@guardian/cdk/lib/constructs/core' ;
66import type { App } from 'aws-cdk-lib' ;
7+ import { RemovalPolicy , Tags } from 'aws-cdk-lib' ;
78import { Duration } from 'aws-cdk-lib' ;
89import {
910 ComparisonOperator ,
1011 Metric ,
1112 TreatMissingData ,
1213 Unit ,
1314} from 'aws-cdk-lib/aws-cloudwatch' ;
15+ import { AttributeType , BillingMode , Table } from 'aws-cdk-lib/aws-dynamodb' ;
1416import { Schedule } from 'aws-cdk-lib/aws-events' ;
1517import { Effect , PolicyStatement } from 'aws-cdk-lib/aws-iam' ;
1618import { LoggingFormat , Runtime } from 'aws-cdk-lib/aws-lambda' ;
@@ -24,11 +26,6 @@ export class FootballNotificationsLambda extends GuStack {
2426 const { stack, stage, region, account } = this ;
2527 const app = 'football' ;
2628
27- const yamlTemplateFilePath = join ( __dirname , '../../football/cfn.yaml' ) ;
28- new CfnInclude ( this , 'YamlTemplate' , {
29- templateFile : yamlTemplateFilePath ,
30- } ) ;
31-
3229 const footballnotificationslambda = new GuScheduledLambda (
3330 this ,
3431 `${ app } -Lambda` ,
@@ -68,9 +65,29 @@ export class FootballNotificationsLambda extends GuStack {
6865 } ) ,
6966 ) ;
7067
71- // Keep dynoma table defition in the yaml for now
7268 const dynamoTableName = `${ stack } -football-notifications-${ stage } ` ;
7369
70+ const dynamoTable = new Table ( this , 'DynamoTable' , {
71+ tableName : dynamoTableName ,
72+ partitionKey : { name : 'notificationId' , type : AttributeType . STRING } ,
73+ billingMode : BillingMode . PROVISIONED ,
74+ readCapacity : 3 ,
75+ writeCapacity : 3 ,
76+ timeToLiveAttribute : 'ttl' ,
77+ removalPolicy : RemovalPolicy . RETAIN ,
78+ } ) ;
79+ Tags . of ( dynamoTable ) . add ( 'devx-backup-enabled' , 'true' ) ;
80+
81+ footballnotificationslambda . addToRolePolicy (
82+ new PolicyStatement ( {
83+ actions : [ 'dynamodb:PutItem' , 'dynamodb:UpdateItem' , 'dynamodb:Query' ] ,
84+ effect : Effect . ALLOW ,
85+ resources : [
86+ `arn:aws:dynamodb:${ region } :${ account } :table/${ dynamoTableName } ` ,
87+ ] ,
88+ } ) ,
89+ ) ;
90+
7491 footballnotificationslambda . addToRolePolicy (
7592 new PolicyStatement ( {
7693 actions : [ 'dynamodb:PutItem' , 'dynamodb:UpdateItem' , 'dynamodb:Query' ] ,
0 commit comments