/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ //snippet-sourcedescription:[eb_putevents.js demonstrates how to send custom events to Amazon EventBridge (formerly Amazon CloudWatch) events so they can be matched with rules.] //snippet-service:[cw_events] //snippet-keyword:[JavaScript] //snippet-sourcesyntax:[javascript] //snippet-keyword:[Code Sample] //snippet-keyword:[Amazon EventBridge] //snippet-sourcetype:[full-example] //snippet-sourcedate:[2018-06-02] //snippet-sourceauthor:[AWS-JSDG] // snippet-start:[eventBridge.JavaScript.eb.putEvents] // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create CloudWatchEvents service object var ebevents = new AWS.EventBridge({apiVersion: '2015-10-07'}); var params = { Entries: [ { Detail: '{ \"key1\": \"value1\", \"key2\": \"value2\" }', DetailType: 'appRequestSubmitted', Resources: [ 'RESOURCE_ARN', ], Source: 'com.company.app' } ] }; ebevents.putEvents(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.Entries); } }); // snippet-end:[eventBridge.JavaScript.eb.putEvents]