@@ -7,11 +7,9 @@ import {
77 aws_events as events ,
88 aws_events_targets as targets ,
99 aws_iam as iam ,
10- aws_lambda as lambda ,
1110 aws_lambda_nodejs as nodejsLambda ,
1211 aws_s3 as s3 ,
1312 aws_s3_notifications as s3n ,
14- aws_sqs as sqs ,
1513 Duration ,
1614 NestedStack ,
1715 NestedStackProps ,
@@ -43,7 +41,6 @@ interface ChannelsStackProps extends NestedStackProps {
4341 resourceConfig : ChannelsResourceConfig ;
4442 tags : { [ key : string ] : string } ;
4543 cognitoCleanupScheduleExp : string ;
46- stageCleanupScheduleExp : string ;
4744}
4845
4946export class ChannelsStack extends NestedStack {
@@ -70,12 +67,7 @@ export class ChannelsStack extends NestedStack {
7067 const region = Stack . of ( this . nestedStackParent ! ) . region ;
7168 const nestedStackName = 'Channels' ;
7269 const stackNamePrefix = `${ parentStackName } -${ nestedStackName } ` ;
73- const {
74- resourceConfig,
75- cognitoCleanupScheduleExp,
76- stageCleanupScheduleExp,
77- tags
78- } = props ;
70+ const { resourceConfig, cognitoCleanupScheduleExp, tags } = props ;
7971
8072 // Configuration variables based on the stage (dev or prod)
8173 const {
@@ -496,21 +488,6 @@ export class ChannelsStack extends NestedStack {
496488 resources : [ userPool . userPoolArn ]
497489 } ) ;
498490
499- // Cleanup idle stages lambda
500- const cleanupIdleStagesHandler = new nodejsLambda . NodejsFunction (
501- this ,
502- `${ stackNamePrefix } -CleanupIdleStages-Handler` ,
503- {
504- logRetention : 7 ,
505- runtime : lambda . Runtime . NODEJS_16_X ,
506- bundling : { minify : true } ,
507- functionName : `${ stackNamePrefix } -CleanupIdleStages` ,
508- entry : getLambdaEntryPath ( 'cleanupIdleStages' ) ,
509- timeout : Duration . minutes ( 10 ) ,
510- initialPolicy : [ deleteIdleStagesIvsPolicyStatement ]
511- }
512- ) ;
513-
514491 // Cleanup unverified users lambda
515492 const cleanupUnverifiedUsersHandler = new nodejsLambda . NodejsFunction (
516493 this ,
@@ -528,18 +505,6 @@ export class ChannelsStack extends NestedStack {
528505 }
529506 ) ;
530507
531- // Scheduled cleanup idle stages lambda function
532- new events . Rule ( this , 'Cleanup-Idle-Stages-Schedule-Rule' , {
533- schedule : events . Schedule . expression ( stageCleanupScheduleExp ) ,
534- ruleName : `${ stackNamePrefix } -CleanupIdleStages-Schedule` ,
535- targets : [
536- new targets . LambdaFunction ( cleanupIdleStagesHandler , {
537- maxEventAge : Duration . minutes ( 2 ) ,
538- retryAttempts : 2
539- } )
540- ]
541- } ) ;
542-
543508 // Scheduled cleanup unverified users lambda function
544509 new events . Rule ( this , 'Cleanup-Unverified-Users-Schedule-Rule' , {
545510 schedule : events . Schedule . expression ( cognitoCleanupScheduleExp ) ,
@@ -553,29 +518,32 @@ export class ChannelsStack extends NestedStack {
553518 } ) ;
554519
555520 // Create a SQS message on Stage Participant Unpublished event
556- const unpublishedParticipantRule = new events . Rule ( this , `${ stackNamePrefix } -UnpublishedParticipant-Rule` , {
557- ruleName : `${ stackNamePrefix } -UnpublishedParticipant-Rule` ,
558- eventPattern : {
559- source : [ 'aws.ivs' ] ,
560- detailType : [ 'IVS Stage Update' ] ,
561- detail : {
562- 'event_name' : [ 'Participant Unpublished' ] ,
563- 'user_id' : [ { 'prefix' : 'host:' } ]
521+ const unpublishedParticipantRule = new events . Rule (
522+ this ,
523+ `${ stackNamePrefix } -UnpublishedParticipant-Rule` ,
524+ {
525+ ruleName : `${ stackNamePrefix } -UnpublishedParticipant-Rule` ,
526+ eventPattern : {
527+ source : [ 'aws.ivs' ] ,
528+ detailType : [ 'IVS Stage Update' ] ,
529+ detail : {
530+ event_name : [ 'Participant Unpublished' ] ,
531+ user_id : [ { prefix : 'host:' } ]
532+ }
564533 }
565534 }
566- } ) ;
535+ ) ;
567536
568537 unpublishedParticipantRule . addTarget (
569538 new targets . SqsQueue ( deleteStageQueue , {
570539 messageGroupId : MESSAGE_GROUP_IDS . DELETE_STAGE_MESSAGE ,
571- message :
572- RuleTargetInput . fromObject ( {
540+ message : RuleTargetInput . fromObject ( {
573541 stageArn : EventField . fromPath ( '$.resources[0]' ) ,
574542 sessionId : EventField . fromPath ( '$.detail.session_id' ) ,
575- userId : EventField . fromPath ( '$.detail.user_id' ) ,
543+ userId : EventField . fromPath ( '$.detail.user_id' )
576544 } )
577545 } )
578- )
546+ ) ;
579547
580548 const containerEnv = {
581549 CHANNEL_ASSETS_BUCKET_NAME : channelAssetsBucket . bucketName ,
0 commit comments