constructor()

in transcribe-ui-backend/provisioning/lib/construct/batch.ts [16:52]


  constructor(scope: cdk.Construct, id: string, props: BatchProps) {
    super(scope, id)

    const updateVocabFunc = new LambdaFunction(this, `${id}-update-vocab`, {
      entry: './lambda/batch.ts',
      environment: {
        VOCABULARY_TABLE: props.vocabTable.tableName,
        TRANSCRIBE_BUCKET: props.transBucket.bucketName
      }
    })
    updateVocabFunc.role!.addToPrincipalPolicy(
      new iam.PolicyStatement({
        effect: iam.Effect.ALLOW,
        resources: ['*'],
        actions: [
          'transcribe:UpdateVocabulary',
          'transcribe:CreateVocabulary',
          'transcribe:GetVocabulary'
        ]
      })
    )
    props.vocabTable.grantReadWriteData(updateVocabFunc)
    props.transBucket.grantReadWrite(updateVocabFunc)

    const eventTarget = new eventsTargets.LambdaFunction(updateVocabFunc)

    const rule = new events.Rule(this, `${id}-lambda-event-rule`, {
      schedule: events.Schedule.cron({
        minute: '0',
        hour: '17',
        day: '*',
        month: '*',
        year: '*'
      }),
      targets: [eventTarget]
    })
  }