Skip to content

Can not delete EventBridge rule target & EventBridge rule #6671

@lampvux

Description

@lampvux

Checkboxes for prior research

Describe the bug

I used AWS sdk v3 to delete eventbridge Rule Target & Rule, the response returned with both httpStatusCode 200. But the rule does not removed.

I used this aws lambda function to invoke :

    import {
      RemoveTargetsCommand,
      EventBridgeClient,
      DeleteRuleCommand
    } from "@aws-sdk/client-eventbridge";

    export const handler = async (event, context) => {
      try {
        // after delete an webhook, delete the rule target in event bridge
        const eventbridgeConfig = {};
        const client = new EventBridgeClient(eventbridgeConfig);
        const removeTargetsParams = {
          EventBusName: "lam",
          Force: true,
          Ids: [`my-id`], // required
          Rule: "my-rule", // required
        };
    
        const command = new RemoveTargetsCommand(removeTargetsParams);
        const response = await client.send(command);
    
        if (response.$metadata.httpStatusCode === 200) {
          // after the api destination is deleted, delete the rule in event bridge
          const deleteRuleParams = {
            EventBusName: process.env.EVENTBUS_NAME || 'default',
            Force: true,
            Name: "my-rule", // required
          };
          
          const deleterulecommand = new DeleteRuleCommand(deleteRuleParams);
          const response = await client.send(deleterulecommand);      
        }
      } catch (err) {
        console.error(err);
      }
    };

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

"@aws-sdk/[email protected]"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

20.16.0

Reproduction Steps

use the lambda function above and test it with the id target rule & rule name

Observed Behavior

returned both success with delete target & rule :

{
  '$metadata': {
    httpStatusCode: 200,
    requestId: '20ab194e-93ae-4db9-b08b-80ca7195f59e',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  FailedEntries: [],
  FailedEntryCount: 0
}

But no rule was deleted. I checked in the AWS Dashboard Console

Expected Behavior

EventBridge Rule deleted

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions