Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.
|
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||
|
|
// SPDX-License-Identifier: Apache-2.0
|
||
|
|
|
||
|
|
// snippet-start:[eventBridge.JavaScript.eb.putTargets]
|
||
|
|
// 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 = {
|
||
|
|
Rule: "DEMO_EVENT",
|
||
|
|
Targets: [
|
||
|
|
{
|
||
|
|
Arn: "LAMBDA_FUNCTION_ARN",
|
||
|
|
Id: "myEventBridgeTarget",
|
||
|
|
},
|
||
|
|
],
|
||
|
|
};
|
||
|
|
|
||
|
|
ebevents.putTargets(params, function (err, data) {
|
||
|
|
if (err) {
|
||
|
|
console.log("Error", err);
|
||
|
|
} else {
|
||
|
|
console.log("Success", data);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
// snippet-end:[eventBridge.JavaScript.eb.putTargets]
|