/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ //snippet-sourcedescription:[eb_putrule.js demonstrates how to create or update an Amazon EventBridge (formerly Amazon CloudWatch) rule.] //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.putRule] // 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 = { Name: 'DEMO_EVENT', RoleArn: 'IAM_ROLE_ARN', ScheduleExpression: 'rate(5 minutes)', State: 'ENABLED' }; ebevents.putRule(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.RuleArn); } }); // snippet-end:[eventBridge.JavaScript.eb.putRule]