constructor()

in source/lib/solution-builders-anonymous-statistics.ts [38:76]


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

        const generateUuid = new lambda.Function(this, 'GenerateUuid', {
            functionName: `${cdk.Aws.STACK_NAME}-generateUuid`,
            description: 'This function generates UUID for each deployment',
            runtime: lambda.Runtime.NODEJS_14_X,
            handler: 'index.handler',
            memorySize: 256,
            timeout: cdk.Duration.seconds(20),
            code: lambda.Code.fromAsset('lambda/generateUuid')
        });
        CfnNagSuppressor.addLambdaSuppression(generateUuid);

        const genereateUuidTrigger = new cdk.CustomResource(this, 'GenerateUuidTrigger', {
            serviceToken: generateUuid.functionArn
        });

        const sendAnonymousStats = new lambda.Function(this, 'SendAnonymousStats', {
            functionName: `${cdk.Aws.STACK_NAME}-sendAnonymousStats`,
            description: 'This function sends anonymous statistics to the AWS Solutions Builders team',
            runtime: lambda.Runtime.NODEJS_14_X,
            handler: 'index.handler',
            memorySize: 128,
            timeout: cdk.Duration.minutes(5),
            code: lambda.Code.fromAsset('lambda/sendAnonymousStats'),
            environment:{
                UUID: genereateUuidTrigger.getAttString('UUID'),
                REGION: cdk.Aws.REGION,
                SOLUTION_ID: props.solutionId,
                VERSION: '%%VERSION%%',
                STORAGE_CLASS: props.destinationStorageClass,
                RETRIEVAL_TIER: props.retrievalTier,
                SEND_ANONYMOUS_STATISTICS: props.sendAnonymousSelection
            }
        });
        CfnNagSuppressor.addLambdaSuppression(sendAnonymousStats);
        this.sendAnonymousStats = sendAnonymousStats;
    }