Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

lym953
Copy link
Contributor

@lym953 lym953 commented Nov 7, 2024

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 #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:

  • applyLayers()

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

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@lym953 lym953 marked this pull request as ready for review November 7, 2024 21:44
@lym953 lym953 requested a review from a team as a code owner November 7, 2024 21:44
@lym953 lym953 force-pushed the yiming.luo/fix-nodejs-latest-2 branch from c4a32a5 to e25d207 Compare November 20, 2024 20:41
@@ -27,7 +27,7 @@ const layers: Map<string, lambda.ILayerVersion> = new Map();
export function applyLayers(
scope: Construct,
region: string,
lambdas: lambda.Function[],
lam: lambda.Function,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (optional)

Suggested change
lam: lambda.Function,
lambda: lambda.Function,

@lym953
Copy link
Contributor Author

lym953 commented Nov 21, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Nov 21, 2024

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-11-21 19:05:07 UTC ℹ️ MergeQueue: pull request added to the queue

The median merge time in main is 8m.

@dd-mergequeue dd-mergequeue bot merged commit 07abcbc into main Nov 21, 2024
13 checks passed
@dd-mergequeue dd-mergequeue bot deleted the yiming.luo/fix-nodejs-latest-2 branch November 21, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants