in source/infrastructure/lib/solution-helper-construct.ts [37:89]
constructor(scope: Construct, id: string, props: SolutionHelperProps) {
super(scope, id);
const helperFunction = buildLambdaFunction(this, {
lambdaFunctionProps: {
runtime: Runtime.PYTHON_3_8,
handler: 'lambda_function.handler',
description:
'This function generates UUID for each deployment and sends anonymous data to the AWS Solutions team',
code: Code.fromAsset('../services/solution-helper'),
timeout: Duration.seconds(30),
},
});
this._createIdFunction = new CustomResource(this, 'CreateUniqueID', {
serviceToken: helperFunction.functionArn,
properties: {
Resource: 'UUID',
},
resourceType: 'Custom::CreateUUID',
});
const sendDataFunction = new CustomResource(this, 'SendAnonymousData', {
serviceToken: helperFunction.functionArn,
properties: {
Resource: 'AnonymousMetric',
SolutionId: props.solutionId,
UUID: this._createIdFunction.getAttString('UUID'),
Region: Aws.REGION,
Version: props.solutionVersion,
botName: props.botName,
botGender: props.botGender,
botLanguage: props.botLanguage,
},
resourceType: 'Custom::AnonymousData',
});
/** Suppression for cfn nag W92 */
const cfnFunction = helperFunction.node.defaultChild as CfnFunction;
CfnNagHelper.addSuppressions(cfnFunction, {
Id: 'W92',
Reason: 'This function does not need to have specified reserved concurrent executions'
});
/** Add the metricsCondition to the resources */
(helperFunction.node.defaultChild as CfnFunction).cfnOptions.condition =
props.sendAnonymousDataCondition;
(this._createIdFunction.node
.defaultChild as CfnFunction).cfnOptions.condition =
props.sendAnonymousDataCondition;
(sendDataFunction.node.defaultChild as CfnFunction).cfnOptions.condition =
props.sendAnonymousDataCondition;
}