Eventbridge Events Names do not match the Lambda Name Pattern
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
Problem is super simple but this affects running two of the same chalice apps in the same AWS Account.
If I create a new function with a 'Rate' to apply a regular schedule
`@upload_private.schedule(Rate(3, unit=Rate.MINUTES))
def process_uploads(event):`
And my Chalice config has an app name
`...version = "2.0"
app_name = "dev-backend"
autogen_policy = false
stages = {
app = {
api_gateway_stage = "api"
environment_variables = {...`
Then correctly chalice will create a lambda function with the name:
"dev-backend-process_uploads"
Fantastic so if I create another app with the app_name = "stage-backend" the lambda function becomes
"stage-backend-process_uploads"
Sweet! they are different and do not conflict... However in order to create that lambda trigger chalice has to make an eventbridge event (aka cloudwatch event) in order to start that code on the schedule requested.
This is where the bug is, for some reason the current latest version of chalice creates the name in eventbridge as ONLY the function name and drops the app name completely. So if these two apps deploy they will fight for this asset back and forth.
Example problematic cloudwatch/eventbridge event name:
"process_uploads"
Can you please fix it so that the name for the lambda function matches the name in the event trigger? Basically append appname+functionname to avoid conflicts in the name?
Its probably a one line change somewhere but I am not a python expert so I am lacking the knowledge to create a PR.
FYI: In my use-case I am using the terraform package output and I am not sure if the problem lies there.
Helpful hint we are looking for the section of the code that creates the AWS "aws_cloudwatch_event_rule" object.
Contributor guide
Research direction
Start by locating the code that creates the AWS aws_cloudwatch_event_rule object, especially the Terraform package output, and compare its event name with the Lambda naming path. Done means scheduled functions from apps with different app_name values produce distinct event-rule names that include the app and function names, without conflicts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100