DataDog / datadog-cdk-constructs

CDK construct library to automagically instrument your Lambda functions with Datadog
Apache License 2.0
65 stars 28 forks source link

chore: Make helpers take one, not multiple Lambda functions (1/x) #317

Closed lym953 closed 2 weeks ago

lym953 commented 3 weeks ago

Context

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:

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:

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

Additional Notes

Types of Changes

Check all that apply

lym953 commented 2 weeks ago

/merge

dd-devflow[bot] commented 2 weeks ago

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-11-07 15:54:16 UTC :information_source: MergeQueue: pull request added to the queue

The median merge time in main is 8m.