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

memory and timeout vars for lambda@edge #330

Merged

Conversation

mihaiplesa
Copy link
Contributor

@mihaiplesa mihaiplesa commented Jan 11, 2025

what

Allow to configure memory size and timeout for Lambda@Edge module.

why

These fields are not configurable now.

references

Resolves #331

@mihaiplesa mihaiplesa requested review from a team as code owners January 11, 2025 09:36
Copy link

coderabbitai bot commented Jan 11, 2025

📝 Walkthrough

Walkthrough

The changes introduce two new configuration parameters, memory_size and timeout, to the Lambda@Edge module across multiple files. These parameters allow users to specify the memory allocation and maximum execution time for Lambda functions. The modifications are consistently implemented in the Terraform configuration, module variables, main resource definition, and module documentation, enhancing the control over Lambda function resources.

Changes

File Change Summary
examples/complete/lambda-at-edge.tf Added memory_size = 128 and timeout = 3 to module configuration
modules/lambda@edge/README.md Updated documentation for new input variable functions to include memory_size and timeout
modules/lambda@edge/main.tf Updated aws_lambda_function resource to include memory_size and timeout parameters
modules/lambda@edge/variables.tf Introduced new attributes memory_size and timeout with default values
README.md Added memory_size and timeout parameters to Lambda@Edge function configuration
README.yaml Updated Lambda function configuration with memory_size = 128 and timeout = 3

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8aadae4 and c521a49.

📒 Files selected for processing (1)
  • examples/complete/lambda-at-edge.tf (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/complete/lambda-at-edge.tf
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mergify mergify bot added the triage Needs triage label Jan 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c95097f and a2d3444.

📒 Files selected for processing (4)
  • examples/complete/lambda-at-edge.tf (1 hunks)
  • modules/lambda@edge/README.md (1 hunks)
  • modules/lambda@edge/main.tf (1 hunks)
  • modules/lambda@edge/variables.tf (1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
modules/lambda@edge/README.md

74-74: Element: a
Inline HTML

(MD033, no-inline-html)


75-75: Element: a
Inline HTML

(MD033, no-inline-html)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (1)
modules/lambda@edge/main.tf (1)

85-86: LGTM! Variables are properly integrated

The memory_size and timeout variables are correctly added to the aws_lambda_function resource.

@mihaiplesa
Copy link
Contributor Author

@coderabbitai full review

Copy link

coderabbitai bot commented Jan 11, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
examples/complete/lambda-at-edge.tf (1)

35-36: 🧹 Nitpick (assertive)

Consider function-specific configurations.

While the current configuration works, consider adjusting memory and timeout based on function type:

  • Viewer functions (request/response): Lower timeout (max 5s)
  • Origin functions (request/response): Higher timeout if needed (max 30s)

Example configuration:

 viewer_request = {
   ...
   memory_size  = 128
-  timeout      = 3
+  timeout      = 5  # Maximum allowed for viewer functions
   ...
 }
 origin_response = {
   ...
   memory_size  = 128
-  timeout      = 3
+  timeout      = 30  # Maximum allowed for origin functions
   ...
 }

Also applies to: 45-46, 54-55, 88-89

modules/lambda@edge/README.md (1)

76-76: 🧹 Nitpick (assertive)

Enhance documentation with Lambda@Edge constraints.

Consider adding Lambda@Edge specific constraints to the documentation:

 | <a name="input_functions"></a> [functions](#input_functions) | Lambda@Edge functions to create.<br><br>The key of this map is the name label of the Lambda@Edge function.<br><br>`source.filename` and `source.content` dictate the name and content of the files that will make up the Lambda function<br>source, respectively.<br><br>`runtime`, `handler`, `memory_size`, and `timeout` correspond to the attributes of the same name in the [lambda_function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function)<br>resource.<br><br>`event_type` and `include_body` correspond to the attributes of the same name in the [Lambda Function association block<br>of the cloudfront_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#lambda-function-association)<br>resource. |
+<br><br>Lambda@Edge specific constraints:<br>
+- `memory_size`: Must be between 128 MB and 10240 MB<br>
+- `timeout`: Must be between 1 and 30 seconds. Note that viewer-request and viewer-response functions have a 5-second timeout limit, while origin-request and origin-response functions have a 30-second limit. |
🧰 Tools
🪛 Markdownlint (0.37.0)

76-76: Element: a
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: pre
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c95097f and 27acd86.

📒 Files selected for processing (6)
  • README.md (1 hunks)
  • README.yaml (1 hunks)
  • examples/complete/lambda-at-edge.tf (3 hunks)
  • modules/lambda@edge/README.md (1 hunks)
  • modules/lambda@edge/main.tf (1 hunks)
  • modules/lambda@edge/variables.tf (1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
modules/lambda@edge/README.md

76-76: Element: a
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: pre
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)


76-76: Element: br
Inline HTML

(MD033, no-inline-html)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (3)
modules/lambda@edge/variables.tf (1)

32-33: LGTM! Consider implementing the suggested validations.

The addition of memory_size and timeout as optional parameters is correct. However, as suggested in previous review comments, consider adding validation blocks to enforce Lambda@Edge specific constraints:

  • Memory: 128MB to 10240MB
  • Timeout: 1-30s (with 5s limit for viewer functions)
modules/lambda@edge/main.tf (1)

81-82: LGTM! Conservative default values.

The implementation correctly sets conservative default values:

  • memory_size = 128 (minimum allowed)
  • timeout = 3 (safe for all function types)
README.yaml (1)

358-359: LGTM! Example is consistent.

The example configuration is consistent with the implementation and uses safe default values.

@joe-niland
Copy link
Member

/terratest

@mihaiplesa mihaiplesa requested a review from joe-niland January 13, 2025 16:48
@joe-niland joe-niland added the patch A minor, backward compatible change label Jan 13, 2025
@joe-niland
Copy link
Member

/terratest

@GabisCampana
Copy link

@goruha

@mihaiplesa
Copy link
Contributor Author

@joe-niland any idea why test are failing?

@joe-niland
Copy link
Member

/terratest

@joe-niland
Copy link
Member

@mihaiplesa I think it's due to SCP changes in the test account. I'll see if I can get an update.

@GabisCampana
Copy link

@goruha

@goruha
Copy link
Member

goruha commented Feb 18, 2025

/terratest

1 similar comment
@goruha
Copy link
Member

goruha commented Feb 18, 2025

/terratest

@goruha
Copy link
Member

goruha commented Feb 18, 2025

/terratest

@mihaiplesa
Copy link
Contributor Author

Looks like tests finally passed, thanks @goruha.

@goruha
Copy link
Member

goruha commented Feb 18, 2025

@mihaiplesa yes. But pls do not merge it yet.
I'm still working on SCP configs

@goruha
Copy link
Member

goruha commented Feb 18, 2025

/terratest

3 similar comments
@goruha
Copy link
Member

goruha commented Feb 18, 2025

/terratest

@goruha
Copy link
Member

goruha commented Feb 18, 2025

/terratest

@goruha
Copy link
Member

goruha commented Feb 19, 2025

/terratest

@mergify mergify bot removed the triage Needs triage label Feb 19, 2025
@mihaiplesa
Copy link
Contributor Author

@hans-d you're set as code owner on this, can you help by approving? Thank you in advance.

@goruha goruha merged commit 6ae1217 into cloudposse:main Feb 19, 2025
29 checks passed
Copy link
Contributor

These changes were released in v0.96.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory size and timeout are not passed to Lambda@Edge
5 participants