Add configurable Lambda resources and Function URL support#12
Merged
ncipollina merged 4 commits intoJul 9, 2025
Merged
Conversation
- Add MemorySize (default: 1024 MB) for configurable memory allocation - Add TimeoutInSeconds (default: 6 seconds) for configurable timeout - Add GenerateUrl (default: false) for optional Function URL generation - Expose public LambdaFunction and LiveAliasFunctionUrlDomain properties - Update LambdaFunctionConstructPropsBuilder with new fluent methods - Add comprehensive test assertion helpers for new functionality - Enhance test customization system with generateUrl parameter - Add 9 comprehensive unit tests covering all new features - Update README with examples and documentation - Maintain backward compatibility with sensible defaults 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove (int) cast from MemorySize assignment in LambdaFunctionConstruct - Remove (int) casts from test assertions for consistency - AWS CDK MemorySize and Timeout properties accept double directly - Improves code clarity and maintains type consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove ShouldHaveCustomResourceConfiguration() method that duplicated ShouldHaveMemorySize and ShouldHaveTimeout - Remove WithoutGenerateUrl() method in favor of WithGenerateUrl(bool) parameter - Update test files to use consolidated WithGenerateUrl(false) instead of WithoutGenerateUrl() - All 151 tests pass successfully after changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove ShouldHaveCustomResourceConfiguration reference (method was removed) - Remove WithoutGenerateUrl reference (method was removed in favor of WithGenerateUrl(bool)) - Documentation now matches current implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ncipollina
deleted the
feature/lambda-configurable-resources-and-function-urls
branch
July 9, 2025 00:10
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR makes the Lambda construct’s memory size and timeout configurable and adds optional Function URL support, updating tests and documentation accordingly.
- Expose
MemorySize,TimeoutInSeconds, andGenerateUrlin props and builder - Wire through configuration into
LambdaFunctionConstructand add new function URL logic - Update test fixtures, assertions, and README to cover and document the new options
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/.../LambdaFunctionConstructCustomization.cs | Pass new generateUrl flag into AutoFixture customizer |
| test/.../LambdaFunctionConstructAutoDataAttribute.cs | Accept generateUrl parameter for auto data attribute |
| test/LambdaFunctionConstructTests.cs | Add and update tests for memory, timeout, and URLs |
| src/.../LambdaFunctionConstructPropsBuilder.cs | Introduce WithMemorySize, WithTimeoutInSeconds, and WithGenerateUrl builder methods |
| src/.../LambdaFunctionConstructAssertions.cs | Add assertion helpers for memory, timeout, and URLs |
| src/.../Models/LambdaFunctionConstructProps.cs | Define new props with default memory, timeout, and URL flag |
| src/.../LambdaFunctionConstruct.cs | Apply configurable memory/timeout and conditional URL setup |
| README.md | Document new options and examples |
Comments suppressed due to low confidence (2)
src/LayeredCraft.Cdk.Constructs/Models/LambdaFunctionConstructProps.cs:12
- MemorySize and TimeoutInSeconds are declared as double but AWS Lambda memory and timeout values must be integers. Consider using int types to improve type safety and prevent fractional values.
double MemorySize { get; set; }
src/LayeredCraft.Cdk.Constructs/Testing/LambdaFunctionConstructPropsBuilder.cs:17
- The builder stores memory and timeout values as double. Consider using int to match the underlying integer-based AWS Lambda configuration and avoid fractional assignments.
private double _memorySize = 1024;
| }); | ||
|
|
||
| if (outputs.Count != 1) | ||
| throw new Exception($"Expected 1 function URL output but found {outputs.Count}"); |
There was a problem hiding this comment.
[nitpick] Throwing a generic Exception for assertion failures can obscure test failures. Consider using a more specific assertion helper or test framework assertion to deliver clearer error messages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds three new configurable properties to the Lambda construct to provide more flexibility and enable direct HTTP access:
Key Features
🔧 Enhanced Lambda Configuration
LambdaFunctionandLiveAliasFunctionUrlDomainfor advanced scenarios🧪 Comprehensive Testing Support
LambdaFunctionConstructAssertionsgenerateUrlparameter📖 Developer Experience
Examples
Custom Memory and Timeout
Function URL for Direct HTTP Access
Enhanced Testing
Test Plan
generateUrlparameterBreaking Changes
None - this is a fully backward compatible enhancement. All existing functionality is preserved with sensible defaults.
🤖 Generated with Claude Code