- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
RemoveTargetsCommand
Removes the specified targets from the specified rule. When the rule is triggered, those targets are no longer be invoked.
When you remove a target, when the associated rule triggers, removed targets might continue to be invoked. Allow a short period of time for changes to take effect.
This action can partially fail if too many requests are made at the same time. If that happens, FailedEntryCount
is non-zero in the response and each entry in FailedEntries
provides the ID of the failed target and the error code.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CloudWatchEventsClient, RemoveTargetsCommand } from "@aws-sdk/client-cloudwatch-events"; // ES Modules import
// const { CloudWatchEventsClient, RemoveTargetsCommand } = require("@aws-sdk/client-cloudwatch-events"); // CommonJS import
const client = new CloudWatchEventsClient(config);
const input = { // RemoveTargetsRequest
Rule: "STRING_VALUE", // required
EventBusName: "STRING_VALUE",
Ids: [ // TargetIdList // required
"STRING_VALUE",
],
Force: true || false,
};
const command = new RemoveTargetsCommand(input);
const response = await client.send(command);
// { // RemoveTargetsResponse
// FailedEntryCount: Number("int"),
// FailedEntries: [ // RemoveTargetsResultEntryList
// { // RemoveTargetsResultEntry
// TargetId: "STRING_VALUE",
// ErrorCode: "STRING_VALUE",
// ErrorMessage: "STRING_VALUE",
// },
// ],
// };
RemoveTargetsCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Ids Required | string[] | undefined | The IDs of the targets to remove from the rule. |
Rule Required | string | undefined | The name of the rule. |
EventBusName | string | undefined | The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used. |
Force | boolean | undefined | If this is a managed rule, created by an Amazon Web Services service on your behalf, you must specify |
RemoveTargetsCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
FailedEntries | RemoveTargetsResultEntry[] | undefined | The failed target entries. |
FailedEntryCount | number | undefined | The number of failed entries. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
ConcurrentModificationException | client | There is concurrent modification on a rule, target, archive, or replay. |
InternalException | server | This exception occurs due to unexpected causes. |
ManagedRuleException | client | This rule was created by an Amazon Web Services service on behalf of your account. It is managed by that service. If you see this error in response to |
ResourceNotFoundException | client | An entity that you specified does not exist. |
CloudWatchEventsServiceException | Base exception class for all service exceptions from CloudWatchEvents service. |