There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DeleteSubscriptionFilter with an AWS SDK
The following code examples show how to use DeleteSubscriptionFilter.
- C++
- 
            - SDK for C++
- 
NoteThere's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository . Include the required files. #include <aws/core/Aws.h> #include <aws/core/utils/Outcome.h> #include <aws/logs/CloudWatchLogsClient.h> #include <aws/logs/model/DeleteSubscriptionFilterRequest.h> #include <iostream>Delete the subscription filter. Aws::CloudWatchLogs::CloudWatchLogsClient cwl; Aws::CloudWatchLogs::Model::DeleteSubscriptionFilterRequest request; request.SetFilterName(filter_name); request.SetLogGroupName(log_group); auto outcome = cwl.DeleteSubscriptionFilter(request); if (!outcome.IsSuccess()) { std::cout << "Failed to delete CloudWatch log subscription filter " << filter_name << ": " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Successfully deleted CloudWatch logs subscription " << "filter " << filter_name << std::endl; }- 
                    For API details, see DeleteSubscriptionFilter in AWS SDK for C++ API Reference. 
 
- 
                    
 
- Java
- 
            - SDK for Java 2.x
- 
NoteThere's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository . import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException; import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; import software.amazon.awssdk.services.cloudwatchlogs.model.DeleteSubscriptionFilterRequest; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class DeleteSubscriptionFilter { public static void main(String[] args) { final String usage = """ Usage: <filter> <logGroup> Where: filter - The name of the subscription filter (for example, MyFilter). logGroup - The name of the log group. (for example, testgroup). """; if (args.length != 2) { System.out.println(usage); System.exit(1); } String filter = args[0]; String logGroup = args[1]; CloudWatchLogsClient logs = CloudWatchLogsClient.builder() .build(); deleteSubFilter(logs, filter, logGroup); logs.close(); } public static void deleteSubFilter(CloudWatchLogsClient logs, String filter, String logGroup) { try { DeleteSubscriptionFilterRequest request = DeleteSubscriptionFilterRequest.builder() .filterName(filter) .logGroupName(logGroup) .build(); logs.deleteSubscriptionFilter(request); System.out.printf("Successfully deleted CloudWatch logs subscription filter %s", filter); } catch (CloudWatchException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }- 
                    For API details, see DeleteSubscriptionFilter in AWS SDK for Java 2.x API Reference. 
 
- 
                    
 
- JavaScript
- 
            - SDK for JavaScript (v3)
- 
NoteThere's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository . import { DeleteSubscriptionFilterCommand } from "@aws-sdk/client-cloudwatch-logs"; import { client } from "../libs/client.js"; const run = async () => { const command = new DeleteSubscriptionFilterCommand({ // The name of the filter. filterName: process.env.CLOUDWATCH_LOGS_FILTER_NAME, // The name of the log group. logGroupName: process.env.CLOUDWATCH_LOGS_LOG_GROUP, }); try { return await client.send(command); } catch (err) { console.error(err); } }; export default run();- 
                    For API details, see DeleteSubscriptionFilter in AWS SDK for JavaScript API Reference. 
 
- 
                    
- SDK for JavaScript (v2)
- 
NoteThere's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository . // Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create the CloudWatchLogs service object var cwl = new AWS.CloudWatchLogs({ apiVersion: "2014-03-28" }); var params = { filterName: "FILTER", logGroupName: "LOG_GROUP", }; cwl.deleteSubscriptionFilter(params, function (err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data); } });- 
                    For more information, see AWS SDK for JavaScript Developer Guide. 
- 
                    For API details, see DeleteSubscriptionFilter in AWS SDK for JavaScript API Reference. 
 
- 
                    
 
- Kotlin
- 
            - SDK for Kotlin
- 
NoteThere's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository . suspend fun deleteSubFilter( filter: String?, logGroup: String?, ) { val request = DeleteSubscriptionFilterRequest { filterName = filter logGroupName = logGroup } CloudWatchLogsClient.fromEnvironment { region = "us-west-2" }.use { logs -> logs.deleteSubscriptionFilter(request) println("Successfully deleted CloudWatch logs subscription filter named $filter") } }- 
                    For API details, see DeleteSubscriptionFilter in AWS SDK for Kotlin API reference. 
 
-