skip to Main Content

I need to fetch information from a lambda function and remove an existing trigger (EventBridge) from this lambda using CLI (script needs to do that).

Tried to use list-event-source-mappings or delete-event-source-mappings but without success.

Seems like EventBridge isn’t supported yet (showing me only SQS,Kinesis,DynamoDB,MQ,MSK) but maybe I am wrong and there is a solution?


Edit:

I have a working lambda function that has associated trigger with an Eventbridge rule which was already deleted in the past. It no longer exists in my account, but, I still see it under my Lambda trigger (it also says that this rule cannot be found any more because it is deleted – again, it still appears in my Lambda trigger and I want to CLEAN it using CLI.) I wish to DELETE the association (trigger) from my Lambda, not to delete the EventBridge TARGET which is the Lambda.

2

Answers


  1. You should be able to use events command:

    aws events list-rule-names-by-target --target-arn <target_arn>
    

    This will list the names of the rules that are associated with the specified target_arn. You can then use the aws events describe-rule command to get more information about each rule, including the rule id, schedule and pattern.

    aws events describe-rule --name <rule_name>
    

    Now to remove a trigger for a Lambda function in EventBridge:

    aws events remove-targets --rule <rule_name> --ids <target_id>
    

    The target_id is the unique identifier for the trigger that you want to remove, and the rule_name is the name of the rule that the trigger is associated with.

    Login or Signup to reply.
  2. The APIs you are looking for are in the EventBridge events client:

    aws events list-rule-names-by-target --target-arn <lambda-arn>
    aws events list-targets-by-rule --rule <rule-name-from-previous>
    aws events remove-targets --rule <rule-name-from-previous> --ids <target-id-from-previous>
    

    Note: The terminology is a bit confusing. An Event Source Mapping is the technical term for the particular polling-type Lambda integration pattern that handles the sources you mention. It is not related to EventBridge events.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search