constructor()

in source/lib/solution-helper/solution-helper-construct.ts [31:73]


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

        const helperRole = new ExecutionRole(this, 'HelperRole');

        const helperFunction = new lambda.Function(this, 'SolutionHelper', {
            runtime: lambda.Runtime.PYTHON_3_8,
            handler: 'lambda_function.handler',
            description: 'AWS DevOps Monitoring Dashboard Solution - This function generates UUID for each deployment.',
            role: helperRole.Role,
            code: lambda.Code.fromAsset(`${__dirname}/../../lambda/solution_helper`),
            timeout: cdk.Duration.seconds(300),
            environment: {
                UserAgentExtra: `AwsSolution/${props.solutionId}/${props.version}`
            }
        });

        const refhelperFunction =  helperFunction.node.findChild('Resource') as lambda.CfnFunction;
        refhelperFunction.cfnOptions.metadata = {
            cfn_nag: {
                rules_to_suppress: [
                    {
                        id: 'W89',
                        reason: 'There is no need to run this lambda in a VPC'
                    },
                    {
                        id: 'W92',
                        reason: 'There is no need for Reserved Concurrency'
                    }
                ]
            }
        };

        this.solutionHelperLambda = helperFunction;

        this._UuidCustomResource = new cdk.CustomResource(this, 'CreateUniqueID', {
            serviceToken: helperFunction.functionArn,
            properties: {
                'Resource': 'UUID'
            },
            resourceType: 'Custom::CreateUUID'
        });
    }