EventBridge event setting arn with ImportValue causes TypeError
See original GitHub issueBug Report
Description
- What did you do?
- Trying to import a Custom event bus arn from another stack caused a type error.
- What happened?
- Failed with error
- Retried using inline
!ImportValue
syntax also failed - Tried with a hardcoded arn and successfully deployed
- What should’ve happened?
- Stack deploy with event from imported bus
- What’s the content of your
serverless.yml
file?
Framework Core: 1.59.1
Plugin: 3.2.5
SDK: 2.2.1
Components Core: 1.1.2
Components CLI: 1.4.0
service: Example
custom:
env: ${file(.env.yml)}
provider:
name: aws
profile: ${opt:aws-profile, self:custom.env.defaults.profile}
stage: ${opt:stage, self:custom.env.defaults.stage}
region: ${opt:region, self:custom.env.defaults.region}
runtime: nodejs12.x
functions:
testFunc:
handler: src/this/is/a/test.handler
events:
- eventBridge:
eventBus:
Fn::ImportValue: OtherStackBusArn
# also tried -
# eventBus: !ImportValue OtherStackBusArn
pattern:
source:
- event.test
- What’s the output you get when you use the
SLS_DEBUG=*
environment variable (e.g.SLS_DEBUG=* serverless deploy
)
TypeError: EventBus.startsWith is not a function
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/eventBridge/index.js:121:30
at Array.forEach (<anonymous>)
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/eventBridge/index.js:29:28
at Array.forEach (<anonymous>)
at AwsCompileEventBridgeEvents.compileEventBridgeEvents (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/eventBridge/index.js:23:31)
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55
From previous event:
at PluginManager.invoke (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
at PluginManager.spawn (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:509:17)
at Deploy.<anonymous> (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:115:50)
From previous event:
at Object.before:deploy:deploy [as hook] (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:100:30)
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55
From previous event:
at PluginManager.invoke (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:524:24
From previous event:
at PluginManager.run (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/classes/PluginManager.js:524:8)
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/Serverless.js:115:33
at processImmediate (internal/timers.js:439:21)
at process.topLevelDomainCallback (domain.js:130:23)
From previous event:
at Serverless.run (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/lib/Serverless.js:102:74)
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/bin/serverless.js:72:30
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:111:16
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:45:10
at FSReqCallback.oncomplete (fs.js:146:23)
From previous event:
at /######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/bin/serverless.js:72:8
at processImmediate (internal/timers.js:439:21)
at process.topLevelDomainCallback (domain.js:130:23)
From previous event:
at Object.<anonymous> (/######/.nvm/versions/node/v12.13.1/lib/node_modules/serverless/bin/serverless.js:61:4)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
Similar or dependent issues:
- This issue from the forum about partner events seems at least tangentially related
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:41 (31 by maintainers)
Top Results From Across the Web
Troubleshooting Amazon EventBridge - AWS Documentation
My rule ran but my Lambda function wasn't invoked. One reason your Lambda function might not run is if you don't have the...
Read more >awslabs/aws-cdk - Gitter
For some reason, doing SNS subscriptions from my Sqs objects from other stacks isn't working - and I can't ... Arn Export: Name:...
Read more >serverless-step-functions - npm
The following config will attach a schedule event and causes the stateMachine crawl to be called every 2 hours. The configuration allows you...
Read more >What needs to be done to make event bridge invoke a fargate ...
Hello - I have a docker container that is setup as a Fargate task on an ECS cluster. Standalone this works fine. I...
Read more >AWS Lambda Events - Event Bridge - Serverless Framework
The eventBridge event types helps setting up AWS Lambda functions to react to ... event bus ARN with CF intrinsic function as it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@medikoo I have completed work on the branch linked to above to deploy EventBridge resources using CloudFormation. I have no doubt there will be changes needed as it is not a trivial change and I’ve had to do a lot learning about how the framework is operation to complete it. Are you happy for me to create a PR off of it and we can go from there?
Glad to help!
Just to recap, the workaround is not to use an imported value but passing the eventbus’ name instead of the ARN.
This virtually removes the ability of using eventbus’ ARN (it will only work when it’s hardcoded). I believe that’s fine as we can still use eventbus’ name. But, yes, it should be clarified in the documentation.
Summing up: