{"action":"closed","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1214","repository_url":"https://api.github.com/repos/aws/aws-sdk-js","labels_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1214/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1214/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1214/events","html_url":"https://github.com/aws/aws-sdk-js/issues/1214","id":188078528,"number":1214,"title":"CloudWatchEvents putRule/putTargets not triggering Lambda function","user":{"login":"juancabrera","id":355253,"avatar_url":"https://avatars.githubusercontent.com/u/355253?v=3","gravatar_id":"","url":"https://api.github.com/users/juancabrera","html_url":"https://github.com/juancabrera","followers_url":"https://api.github.com/users/juancabrera/followers","following_url":"https://api.github.com/users/juancabrera/following{/other_user}","gists_url":"https://api.github.com/users/juancabrera/gists{/gist_id}","starred_url":"https://api.github.com/users/juancabrera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juancabrera/subscriptions","organizations_url":"https://api.github.com/users/juancabrera/orgs","repos_url":"https://api.github.com/users/juancabrera/repos","events_url":"https://api.github.com/users/juancabrera/events{/privacy}","received_events_url":"https://api.github.com/users/juancabrera/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-08T19:15:11Z","updated_at":"2016-11-28T18:17:39Z","closed_at":"2016-11-28T18:17:39Z","body":"I'm building a node app that is creating a new rule with a `ScheduleExpression` of `rate(5 minutes)` then it's adding a Lambda function as a target to it (adding the respective permissions). But is not triggering the Lambda function even though all looks to be ok on the console. \r\n\r\nOnly way to get it working is going to the Lambda Management Console, get into the function, then on the `Triggers` tab click `disable` and then `enable`.\r\n\r\nResponse I got when creating Rule:\r\n```javascript\r\n{ RuleArn: 'arn:aws:events:us-east-1:111111111111:rule/SyncData' }\r\n```\r\n\r\nResponse I got when adding permissions:\r\n```javascript\r\n{ Statement: '{\"Sid\":\"statementID\",\"Resource\":\"arn:aws:lambda:us-east-1:111111111111:function:FUNCTIONNAME\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"events.amazonaws.com\"},\"Action\":[\"lambda:InvokeFunction\"],\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:events:us-east-1:111111111111:rule/SyncData\"}}}' }\r\n```\r\n\r\nResponse I got when adding target (Lambda function) to Rule:\r\n```javascript\r\n{ FailedEntryCount: 0, FailedEntries: [] }\r\n```\r\n\r\nThis is the code:\r\n```javascript\r\n// Creating Rule\r\ncloudWatchEvents.putRule({\r\n  Name: ruleName, \r\n  ScheduleExpression: 'rate(5 minutes)',\r\n  Description: ruleName\r\n}, (err, data) => {\r\n  if (err) {\r\n    console.log('ERROR: putRule', err, err.stack)\r\n  } else {\r\n    console.log('putRule', data)\r\n    ruleARN = data.RuleArn\r\n    // Add permissions to Lambda Function\r\n    lambda.addPermission({\r\n      Action: 'lambda:InvokeFunction',\r\n      FunctionName: lambdaFunctionName,\r\n      StatementId: 'statementID',\r\n      Principal: 'events.amazonaws.com',\r\n      SourceArn: ruleARN\r\n    }, (err, data) => {\r\n      if (err) {\r\n        console.log('ERROR: addPermission', err, err.stack)\r\n      } else {\r\n        // Adding target to Rule\r\n        cloudWatchEvents.putTargets({\r\n          Rule: ruleName, \r\n          Targets: [{\r\n            'Id': '1', \r\n            'Arn': ruleARN.replace('events', 'lambda').replace('rule', 'function').replace(ruleName, lambdaFunctionName)\r\n          }]\r\n        }, (err, data) => {\r\n            if (err) {\r\n              console.log('ERROR: putTarget', err, err.stack)\r\n            } else {\r\n              console.log('putTarget', data)\r\n            }\r\n        })\r\n      }\r\n    })\r\n  }\r\n})\r\n```\r\nHope this is enough to explain the issue, let me know you guys need more specific info."}}
{"actor":{"display_login":"chrisradek"}}