private addStepFunctionNotifySuccess()

in source/lib/compliant-framework-stack.ts [718:764]


  private addStepFunctionNotifySuccess(
    alertTopic: sns.Topic,
    alertSubscriptionCmk: kms.Key
  ): tasks.LambdaInvoke {
    const functionName = 'CompliantFramework-NotifySuccessFunction'

    const lambdaFunction = new lambda.Function(this, 'notifySuccessFunction', {
      functionName,
      code: new lambda.AssetCode('lambda/notify_success'),
      handler: 'index.lambda_handler',
      timeout: cdk.Duration.seconds(300),
      runtime: lambda.Runtime.PYTHON_3_8,
      environment: {
        ['SNS_TOPIC_ARN']: alertTopic.topicArn
      },
      initialPolicy: [
        new iam.PolicyStatement({
          effect: iam.Effect.ALLOW,
          actions: [
            'logs:CreateLogGroup',
            'logs:CreateLogStream',
            'logs:PutLogEvents'
          ],
          resources: [this.formatArn({
            service: 'logs',
            resource: 'log-group',
            sep: ':',
            resourceName: functionName
          })]
        }),
        new iam.PolicyStatement({
          effect: iam.Effect.ALLOW,
          actions: [
            'sns:Publish'
          ],
          resources: [alertTopic.topicArn]
        })
      ]
    })
    this.suppressWarnings(lambdaFunction)
    alertSubscriptionCmk.grantEncryptDecrypt(lambdaFunction)

    return new tasks.LambdaInvoke(this, 'Notify Success', {
      lambdaFunction,
      payload: sfn.TaskInput.fromDataAt('$')
    })
  }