-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Template: Lambda batch with EventBridge (CloudWatch Events) #56
Conversation
Warning Rate Limit Exceeded@nao1215 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 39 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThis update enhances a project by integrating AWS Serverless Application Model (SAM) for deploying Lambda functions, improving documentation, and introducing a Lambda batch processing feature with EventBridge scheduling. It streamlines deployment processes, enriches the project's README with detailed templates, and provides a clear guide for using Lambda batch processing, thereby improving automation and consistency in scheduled tasks. Changes
Related issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files ignored due to path filters (4)
cloudformation/lambda-batch/lambda-batch-with-event-bridge.svg
is excluded by:!**/*.svg
cloudformation/lambda-batch/template.yml
is excluded by:!**/*.yml
go.mod
is excluded by:!**/*.mod
go.sum
is excluded by:!**/*.sum
Files selected for processing (8)
- .github/workflows/cloudformation.yml (1 hunks)
- README.md (1 hunks)
- cloudformation/Makefile (1 hunks)
- cloudformation/lambda-batch/.gitignore (1 hunks)
- cloudformation/lambda-batch/Makefile (1 hunks)
- cloudformation/lambda-batch/README.md (1 hunks)
- cloudformation/lambda-batch/lambda-batch-with-event-bridge.drawio (1 hunks)
- cloudformation/lambda-batch/main.go (1 hunks)
Files skipped from review due to trivial changes (1)
- cloudformation/lambda-batch/.gitignore
Additional comments: 3
.github/workflows/cloudformation.yml (1)
- 15-17: Verify the
aws-actions/setup-sam@v2
action's compatibility with the project's AWS SAM version to ensure smooth CI/CD operations.README.md (1)
- 46-49: Confirm the implementation percentage for the Lambda batch with EventBridge template is accurate and up-to-date.
cloudformation/lambda-batch/lambda-batch-with-event-bridge.drawio (1)
- 1-40: Ensure the diagram accurately represents the current architecture and flow between Lambda functions and EventBridge, including any recent changes.
cloudformation/Makefile
Outdated
cd static-web-site-distribution && ./deploy.sh | ||
cd lambda-batch && make deploy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the make deploy
command for lambda-batch
includes error handling to manage potential deployment failures.
+ cd lambda-batch && make deploy || { echo "Deployment of lambda-batch failed"; exit 1; }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
cd lambda-batch && make deploy | |
cd lambda-batch && make deploy || { echo "Deployment of lambda-batch failed"; exit 1; } |
cloudformation/lambda-batch/main.go
Outdated
func handler(_ context.Context) error { | ||
fmt.Printf("Hello, world from %s!!\n", os.Getenv("APP_ENV")) | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate the existence of the APP_ENV
environment variable before using it to prevent potential runtime errors.
+ if env, exists := os.LookupEnv("APP_ENV"); exists {
+ fmt.Printf("Hello, world from %s!!\n", env)
+ } else {
+ fmt.Println("Hello, world!!")
+ }
- fmt.Printf("Hello, world from %s!!\n", os.Getenv("APP_ENV"))
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
func handler(_ context.Context) error { | |
fmt.Printf("Hello, world from %s!!\n", os.Getenv("APP_ENV")) | |
return nil | |
func handler(_ context.Context) error { | |
if env, exists := os.LookupEnv("APP_ENV"); exists { | |
fmt.Printf("Hello, world from %s!!\n", env) | |
} else { | |
fmt.Println("Hello, world!!") | |
} | |
return nil |
@command -v sam > /dev/null 2>&1 || { echo "Error: sam is not installed. See https://github.com/aws/aws-sam-cli"; exit 1; } | ||
|
||
build: ## Build binary | ||
GOOS=linux GOARCH=arm64 go build -o $(BINARY_NAME) main.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a check to ensure GOOS
and GOARCH
are compatible with the target Lambda execution environment.
+ @echo "Building for Lambda execution environment (Linux/ARM64)"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
GOOS=linux GOARCH=arm64 go build -o $(BINARY_NAME) main.go | |
@echo "Building for Lambda execution environment (Linux/ARM64)" | |
GOOS=linux GOARCH=arm64 go build -o $(BINARY_NAME) main.go |
cloudformation/lambda-batch/Makefile
Outdated
GOOS=linux GOARCH=arm64 go build -o $(BINARY_NAME) main.go | ||
|
||
deploy: dependency_check build ## Deploy CloudFormation Template | ||
sam deploy --stack-name $(AWS_STACK_NAME) --template-file $(TEMPLATE_FILE) --capabilities CAPABILITY_IAM --resolve-s3 --region ap-northeast-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for the sam deploy
command to manage deployment failures gracefully.
+ sam deploy --stack-name $(AWS_STACK_NAME) --template-file $(TEMPLATE_FILE) --capabilities CAPABILITY_IAM --resolve-s3 --region ap-northeast-1 || { echo "SAM deployment failed"; exit 1; }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
sam deploy --stack-name $(AWS_STACK_NAME) --template-file $(TEMPLATE_FILE) --capabilities CAPABILITY_IAM --resolve-s3 --region ap-northeast-1 | |
sam deploy --stack-name $(AWS_STACK_NAME) --template-file $(TEMPLATE_FILE) --capabilities CAPABILITY_IAM --resolve-s3 --region ap-northeast-1 || { echo "SAM deployment failed"; exit 1; } |
|
||
### How to deploy | ||
```shell | ||
$ make deploy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the make deploy
command in the README includes all necessary prerequisites and setup steps for clarity to new users.
+ Note: Before running `make deploy`, ensure you have configured AWS credentials and set the correct region.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
$ make deploy | |
Note: Before running `make deploy`, ensure you have configured AWS credentials and set the correct region. | |
$ make deploy |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
HOTTEST report
Reported by hottest |
Code Metrics Report
Details | | main (21a2ffd) | #56 (3748661) | +/- |
|---------------------|----------------|---------------|------|
| Coverage | 24.8% | 24.8% | 0.0% |
| Files | 42 | 42 | 0 |
| Lines | 1649 | 1649 | 0 |
| Covered | 409 | 409 | 0 |
| Test Execution Time | 5s | 5s | 0s | Reported by octocov |
Summary by CodeRabbit
.gitignore
to exclude specific build artifacts.