Skip to content

Conversation

bendoerr
Copy link
Member

@bendoerr bendoerr commented Apr 25, 2025

This allows for situations where the source code hash changes after the initial evaluation. For example, the source is built during apply via a null resource.

Summary by CodeRabbit

  • Documentation

    • Updated documentation to specify the AWS provider version as 5.95.0.
    • Documented a new input variable for providing a source code hash to trigger Lambda function updates.
    • Documented a new output variable for the deployed Lambda function's name.
  • New Features

    • Added support for specifying a custom source code hash to control Lambda function updates.

This allows for situations where the source code hash changes after the initial
evaluation. For example, the source is built during apply via a null resource.
Copy link

coderabbitai bot commented Apr 25, 2025

Walkthrough

The changes introduce a new input variable, source_code_hash, to the Terraform module, allowing users to explicitly provide a base64-encoded SHA256 hash to trigger AWS Lambda function updates. If this variable is not set, the hash is computed from the source code file as before. The module's documentation (README.md) has been updated to reflect this new input, as well as a new output variable, lambda_function_name, which exposes the name of the deployed Lambda function. No changes were made to the module's exported resources themselves, aside from the conditional logic for the source code hash.

Changes

File(s) Change Summary
README.md Updated documentation to specify AWS provider version, add source_code_hash input, and lambda_function_name output.
main.tf Modified aws_lambda_function resource to use var.source_code_hash if provided, otherwise compute file hash.
variables.tf Added new variable source_code_hash (string, default null) with description for Lambda update triggering.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Terraform
    participant AWS Lambda

    User->>Terraform: Provide source_code_hash (optional)
    Terraform->>Terraform: Use source_code_hash if provided
    alt source_code_hash not provided
        Terraform->>Terraform: Compute hash from filename
    end
    Terraform->>AWS Lambda: Deploy/Update Lambda with code and hash
    AWS Lambda-->>Terraform: Acknowledge deployment
    Terraform-->>User: Output lambda_function_name
Loading

Poem

In the land of clouds where Lambdas leap,
A hash now guides their nightly sweep.
Provide your own, or let it be,
Terraform checks—automagically!
With names revealed and docs anew,
The code hops forward, fresh and true.
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

@github-actions github-actions bot added the enhancement New feature or request label Apr 25, 2025
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link

💰 Infracost report

Monthly estimate generated

This comment will be updated when code changes.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9a1e44d and a7be16e.

📒 Files selected for processing (3)
  • README.md (3 hunks)
  • main.tf (1 hunks)
  • variables.tf (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: terratest
🔇 Additional comments (3)
variables.tf (1)

151-156: New variable looks correct
The source_code_hash variable is defined consistently with existing defaults and provides the intended override for the computed hash.

README.md (2)

101-101: New input documented correctly
The source_code_hash entry in the inputs table aligns with variables.tf.


117-117: Ensure the output is declared in code
The README lists an lambda_function_name output, but I didn’t spot its declaration in the module. Please verify or add in outputs.tf:

output "lambda_function_name" {
  description = "Name of the deployed Lambda function"
  value       = aws_lambda_function.this.function_name
}

@bendoerr bendoerr merged commit e0ba5ac into main Apr 25, 2025
15 checks passed
@bendoerr bendoerr deleted the feature/source-hash branch April 25, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant