However, this behavior is hard to implement under the current code structure:
public addLambdaFunctions() {
grantReadLambdas(lambdas);
applyLayers(lambdas);
applyExtensionLayer(lambdas);
...
}
If one of the steps skips a Lambda function, it's hard for the subsequent steps to know this and thus skip the Lambda function.
Therefore, at the end of day, I'm going to change the code structure to:
public addLambdaFunctions() {
for (lambda : lambdas) {
addLambdaFunction(lambda);
}
}
public addLambdaFunction() {
if (!grantReadLambda(lambda)) {
return;
}
if (!applyLayers(lambda)) {
return;
}
...
}
to make it possible to implement this behavior.
What does this PR do?
This PR makes these helper functions to take a single Lambda function instead of multiple ones:
addForwarder()
It's not supposed to change code behavior.
I'll handle other helper functions in separate PRs, to keep each PR small and easy to review.
Testing Guidelines
Run snapshot tests: aws-vault exec sso-serverless-sandbox-account-admin -- scripts/run_integration_tests.sh to ensure the generated CloudFormation template for the test stacks are not changed.
Context of this PR series
The end goal of this series of PRs is to abort the instrumentation of a Lambda function if its runtime is not supported, while still instrument other Lambda functions. More in https://github.com/DataDog/datadog-cdk-constructs/issues/314
However, this behavior is hard to implement under the current code structure:
If one of the steps skips a Lambda function, it's hard for the subsequent steps to know this and thus skip the Lambda function.
Therefore, at the end of day, I'm going to change the code structure to:
to make it possible to implement this behavior.
What does this PR do?
This PR makes these helper functions to take a single Lambda function instead of multiple ones:
addForwarder()
It's not supposed to change code behavior.
I'll handle other helper functions in separate PRs, to keep each PR small and easy to review.
Testing Guidelines
Run snapshot tests:
aws-vault exec sso-serverless-sandbox-account-admin -- scripts/run_integration_tests.sh
to ensure the generated CloudFormation template for the test stacks are not changed.Additional Notes
Types of Changes
Check all that apply