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 (7/x) #345

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

lym953
Copy link
Contributor

@lym953 lym953 commented Nov 25, 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:

  • applyEnvVars()
  • addGitCommitMetadata()

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 requested a review from a team as a code owner November 25, 2024 20:38
log.debug(`Setting Datadog transport environment variables...`);
lambdas.forEach((lam) => {
lam.addEnvironment(FLUSH_METRICS_TO_LOGS_ENV_VAR, this.flushMetricsToLogs.toString());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are only indentation changes.

@lym953 lym953 force-pushed the yiming.luo/fix-nodejs-latest-7 branch from 342c625 to 7761033 Compare November 25, 2024 20:42
@lym953 lym953 force-pushed the yiming.luo/fix-nodejs-latest-6 branch 2 times, most recently from 2912f49 to d78bde2 Compare December 5, 2024 20:19
Base automatically changed from yiming.luo/fix-nodejs-latest-6 to main December 5, 2024 20:29
@lym953 lym953 force-pushed the yiming.luo/fix-nodejs-latest-7 branch from 7761033 to f085d48 Compare December 5, 2024 20:34
@lym953
Copy link
Contributor Author

lym953 commented Dec 5, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Dec 5, 2024

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-12-05 20:34:52 UTC ℹ️ MergeQueue: pull request added to the queue

The median merge time in main is 9m.

@dd-mergequeue dd-mergequeue bot merged commit 9d2ac35 into main Dec 5, 2024
14 checks passed
@dd-mergequeue dd-mergequeue bot deleted the yiming.luo/fix-nodejs-latest-7 branch December 5, 2024 20:44
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