From e39b2bb62682cdf1a1ed3fa777f362b61990969b Mon Sep 17 00:00:00 2001 From: oleiade Date: Fri, 29 Sep 2023 11:31:30 +0200 Subject: [PATCH] Add EventBridge example --- examples/event-bridge.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/event-bridge.js diff --git a/examples/event-bridge.js b/examples/event-bridge.js new file mode 100644 index 0000000..444b8d9 --- /dev/null +++ b/examples/event-bridge.js @@ -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}`); + } +} \ No newline at end of file