in source/lib/ingestion/data-ingestion-template.ts [126:160]
constructor(scope: cdk.Construct, id: string, props: DataIngestionTemplateProps) {
super(scope, id);
// start of building target/ query engine lambda, optional DDB, and add optional SSM policy (TARGET)
const _eventTarget = this.buildCustomBusAndAddRules(props);
this._lambda[Qualifier.TARGET] = _eventTarget.lambdaFunction;
if (props.target.credentialKeyPath) {
this._lambda[Qualifier.TARGET].addToRolePolicy(this.buildSSMPolicy(props.target.credentialKeyPath));
}
if (props.target.tableProps || props.target.existingTable) {
const _target = this.buildLambdaAndDynamoDB({
existingLambda: this._lambda[Qualifier.TARGET],
tableProps: props.target.tableProps,
existingTable: props.target.existingTable
}, Qualifier.TARGET);
this._lambda[Qualifier.TARGET] = _target.lambdaFunction
if (_target.ddbTable) {
this._dynamoDB[Qualifier.TARGET] = _target.ddbTable;
}
}
// end of building target/ query engine lambda, optional DDB, and add optional SSM policy
// start of building source trigger lambda and optional DDB (SOURCE)
const _source = this.buildLambdaAndDynamoDB(props.source, Qualifier.SOURCE);
_source.lambdaFunction.addEnvironment("EVENT_BUS_NAME", this._bus.eventBusName)
this._lambda[Qualifier.SOURCE] = _source.lambdaFunction;
if (_source.ddbTable) {
this._dynamoDB[Qualifier.SOURCE] = _source.ddbTable;
}
this._lambda[Qualifier.SOURCE].addToRolePolicy(this.buildPutEventPolicy());
// end of building source trigger and optional DDB
}