Skip to content

Commit

Permalink
Add EventBridge example
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Sep 29, 2023
1 parent 0dfe381 commit e39b2bb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/event-bridge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { AWSConfig, EventBridgeClient } from '../build/event-bridge.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
sessionToken: __ENV.AWS_SESSION_TOKEN,
});

const eventBridge = new EventBridgeClient(awsConfig);

export default async function () {
const eventDetails = {
Source: 'my.custom.source',
Detail: { key1: 'value1', key2: 'value2' },
DetailType: 'MyDetailType',
Resources: ['arn:aws:resource1'],
};

const input = {
Entries: [eventDetails]
};

try {
await eventBridge.putEvents(input);
} catch (error) {
console.error(`Failed to put events: ${error.message}`);
}
}

0 comments on commit e39b2bb

Please sign in to comment.