Fix CloudWatch Logs permissions and add comprehensive testing helpers#2
Merged
ncipollina merged 1 commit intoJul 3, 2025
Conversation
## Summary - Fixed CloudWatch Logs policy to use full function name with suffix - Added comprehensive testing helpers for library consumers - Enhanced documentation and examples ## Changes ### Bug Fixes - Fixed CloudWatch Logs IAM policy resource ARNs to include function suffix - Updated existing tests to match corrected CloudWatch permissions ### New Features - Added testing helpers in `src/LayeredCraft.Cdk.Constructs/Testing/`: - `CdkTestHelper`: Stack creation and asset path utilities - `LambdaFunctionConstructAssertions`: Extension methods for CDK template assertions - `LambdaFunctionConstructPropsBuilder`: Fluent builder for test props - Added comprehensive test coverage for all testing helper methods ### Documentation - Updated README.md with testing helpers documentation and examples - Updated CLAUDE.md with testing infrastructure details and critical patterns - Added examples showing correct CDK template creation timing ## Test Coverage - Added tests for `ShouldHaveEnvironmentVariables` and `ShouldHaveLambdaPermissions` assertions - Added tests for `WithS3Access`, `WithCustomPolicy`, `WithCustomPermission` builder methods - Added tests for `GetTestAssetPath` and `GetTestLambdaZipPath` utility methods 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the CloudWatch Logs IAM policy to include function suffixes and adds a rich set of testing helpers with comprehensive documentation and examples.
- Corrected the CloudWatch Logs policy resource ARNs to use full function name plus suffix
- Introduced testing infrastructure (
CdkTestHelper, assertion extensions, props builder) and updated tests - Enhanced README and CLAUDE.md with usage examples and documentation of new helpers
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/LayeredCraft.Cdk.Constructs/Constructs/LambdaFunctionConstruct.cs | Updated log policy ARNs to include FunctionSuffix |
| src/LayeredCraft.Cdk.Constructs/Testing/ | Added CdkTestHelper, LambdaFunctionConstructPropsBuilder, and LambdaFunctionConstructAssertions |
| test/LayeredCraft.Cdk.Constructs.Tests/Testing/TestingHelpersTests.cs | New tests for the testing helpers |
| test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Extensions/AssetPathExtensions.cs | Added asset‐path resolution extensions |
| README.md | Documented new testing support |
| CLAUDE.md | Updated instructions and helper docs |
Comments suppressed due to low confidence (6)
test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Extensions/AssetPathExtensions.cs:1
- AssetPathExtensions uses Path.Combine and Path.GetDirectoryName but doesn’t import System.IO. Add
using System.IO;to the top of this file so that Path is resolved correctly.
using System.Reflection;
src/LayeredCraft.Cdk.Constructs/Testing/CdkTestHelper.cs:1
- CdkTestHelper calls Path.GetDirectoryName and Path.Combine but lacks
using System.IO;. Add that import to avoid compilation errors.
using System.Reflection;
src/LayeredCraft.Cdk.Constructs/Testing/LambdaFunctionConstructPropsBuilder.cs:1
- This builder uses
List<T>andDictionary<TKey, TValue>but doesn’t importSystem.Collections.Generic. Addusing System.Collections.Generic;at the top.
using Amazon.CDK.AWS.IAM;
src/LayeredCraft.Cdk.Constructs/Testing/LambdaFunctionConstructAssertions.cs:1
- This assertions class builds
Dictionary<string, object>instances but lacksusing System.Collections.Generic;. Add that import to ensure the generic types resolve.
using Amazon.CDK.Assertions;
test/LayeredCraft.Cdk.Constructs.Tests/Testing/TestingHelpersTests.cs:1
- TestingHelpersTests calls
Path.IsPathRootedbut doesn’t importSystem.IO. Addusing System.IO;so Path is recognized.
using Amazon.CDK.Assertions;
test/LayeredCraft.Cdk.Constructs.Tests/Testing/TestingHelpersTests.cs:2
- This test file constructs
Dictionary<string, string>but doesn’t importSystem.Collections.Generic. Addusing System.Collections.Generic;to avoid errors.
using AwesomeAssertions;
ncipollina
deleted the
feature/fix-cloudwatch-logs-permissions-and-testing-helpers
branch
July 3, 2025 19:10
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
Changes Made
🐛 Bug Fixes
function-name-suffixinstead of justfunction-name)✨ New Features
src/LayeredCraft.Cdk.Constructs/Testing/:CdkTestHelper: Utilities for creating test stacks and resolving asset pathsLambdaFunctionConstructAssertions: Extension methods for CDK template assertionsLambdaFunctionConstructPropsBuilder: Fluent builder for creating test props with AWS service integrations📚 Documentation Updates
🧪 Test Coverage
Added comprehensive test coverage for:
ShouldHaveEnvironmentVariablesandShouldHaveLambdaPermissionsassertion methodsWithS3Access,WithCustomPolicy,WithCustomPermissionbuilder methodsGetTestAssetPathandGetTestLambdaZipPathutility methodsTesting Helpers Usage
Test Plan
🤖 Generated with Claude Code