Comments (1)
Hi, can you show me your code. The consuming functions do receive the correct format:
{
version: '0',
id: 'xxxxxxxx-xxxx-xxxx-xxxx-1605085184180',
source: 'acme.newsletter.campaign',
account: '',
time: '2020-11-11T08:59:44.180Z',
region: 'eu-west-1',
resources: [],
detail: { 'E-Mail': '[email protected]' },
'detail-type': 'UserSignUp'
}
Using the following example code:
serverless.yml:
plugins:
- serverless-webpack
- serverless-offline
- serverless-offline-aws-eventbridge
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
serverless-offline:
host: 0.0.0.0
serverless-offline-aws-eventbridge:
port: 4010
debug: true
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: eu-west-1
functions:
publishEvent:
handler: events.publish
events:
- http:
path: publish
method: get
consumeEvent:
handler: events.consume
events:
- eventBridge:
eventBus: marketing
pattern:
source:
- acme.newsletter.campaign
events.js
import AWS from 'aws-sdk';
AWS.config.update({
apiVersion: '2015-10-07',
accessKeyId: "YOURKEY",
secretAccessKey: "YOURSECRET",
region: "eu-west-1"
});
export const publish = async () => {
try {
const eventBridge = new AWS.EventBridge({
endpoint: 'http://127.0.0.1:4010',
region: 'eu-west-1'
});
const test = await eventBridge.putEvents({
Entries: [
{
EventBusName: 'marketing',
Source: 'acme.newsletter.campaign',
DetailType: 'UserSignUp',
Detail: `{ "E-Mail": "[email protected]" }`,
},
]
}).promise();
} catch (e) {
console.error(e);
return { statusCode: 400, body: 'could not publish' };
}
return { statusCode: 200, body: 'published' };
}
export const consume = async (event, context) => {
console.log(event);
return { statusCode: 200, body: 'consume' };
}
Using babel and webpack to transpile everything..
from serverless-offline-eventbridge.
Related Issues (20)
- Event Pattern Matching HOT 5
- context.succeed is not a function HOT 1
- `context.succeed` is not a function HOT 1
- Using intrinsic Cloud Formation functions (!GetAtt and !ImportValue) when defining the event bus name HOT 1
- Serverless deploy freezes on moveArtifactsToPackage with 1.6.0 HOT 13
- PayloadTooLargeError: request entity too large HOT 3
- Request: Update serverless-offline peer dependency HOT 1
- Missing support for schedules HOT 9
- Retry attempts break the execution HOT 2
- Cannot find module 'serverless-offline/dist/lambda' HOT 1
- Unclear error message HOT 2
- serverless-offline 9.1.0 Breaking change HOT 10
- Setting up serverless-offline-eventBridge HOT 3
- cron(*/1 * * * ? *) is worked but cron(0/1 * * * ? *) is not worked HOT 2
- Installation errors with serverless-offline ^11 HOT 1
- eventBridge enabled flag is ignored HOT 7
- equals-ignore-case filter not found HOT 2
- Query: Does this package have support for the event bridge scheduler HOT 2
- Event Pattern doesn't support array of objects. HOT 2
- Stepfunction events HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-offline-eventbridge.