//snippet-sourcedescription:[PutTargets.java demonstrates how to creates a CloudWatch event-routing rule target.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[cloudwatch]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[soo-aws]
// snippet-start:[cloudwatch.java2.put_targets.complete]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.example.cloudwatch;
// snippet-start:[cloudwatch.java2.put_targets.import]
import software.amazon.awssdk.services.cloudwatchevents.CloudWatchEventsClient;
import software.amazon.awssdk.services.cloudwatchevents.model.PutTargetsRequest;
import software.amazon.awssdk.services.cloudwatchevents.model.PutTargetsResponse;
import software.amazon.awssdk.services.cloudwatchevents.model.Target;
// snippet-end:[cloudwatch.java2.put_targets.import]

/**
 * Creates a CloudWatch event-routing rule target
 */
public class PutTargets {

    public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply:\n" +
            "* a rule name\n" +
            "* lambda function arn\n" +
            "* target id\n\n" +
            "Ex: PutTargets <rule-name> <lambda-function-arn> <target-id>\n";

        if (args.length != 3) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String rule_name = args[0];
        String function_arn = args[1];
        String target_id = args[2];

        // snippet-start:[cloudwatch.java2.put_targets.main]
        CloudWatchEventsClient cwe =
        		CloudWatchEventsClient.builder().build();

        Target target = Target.builder()
            .arn(function_arn)
            .id(target_id)
            .build();

        PutTargetsRequest request = PutTargetsRequest.builder()
            .targets(target)
            .rule(rule_name)
            .build();

        PutTargetsResponse response = cwe.putTargets(request);
        // snippet-end:[cloudwatch.java2.put_targets.main]

        System.out.printf(
            "Successfully created CloudWatch events target for rule %s",
            rule_name);
    }
}
// snippet-end:[cloudwatch.java2.put_targets.complete]
@@ -270,16 +270,26 @@
 cedate:%5B
+13/02/2020
 %5D%0D%0A//sni
@@ -312,72 +312,24 @@
 r:%5Bs
-oo-aws%5D%0A// snippet-start:%5Bcloudwatch.java2.put_targets.complete%5D
+cmacdon-aws%5D%0D%0A%0D%0A
 %0D%0A/*
@@ -354,10 +354,10 @@
 0-20
-19
+20
  Ama
@@ -923,17 +923,19 @@
 se.%0D%0A */
-%0A
+%0D%0A 
 package 
@@ -959,16 +959,74 @@
 watch;%0D%0A
+// snippet-start:%5Bcloudwatch.java2.put_targets.complete%5D%0D%0A
 // snipp
@@ -1505,16 +1505,17 @@
 get%0D%0A */
+%0D
 %0Apublic 
@@ -1626,16 +1626,20 @@
         
+    
 %22To run 
@@ -1678,16 +1678,28 @@
         
+           
+ 
 %22* a rul
@@ -1707,24 +1707,36 @@
  name%5Cn%22 +%0D%0A
+            
             
@@ -1776,16 +1776,28 @@
         
+  
+          
 %22* targe
@@ -1801,32 +1801,44 @@
 rget id%5Cn%5Cn%22 +%0D%0A
+            
             %22Ex:
@@ -2036,18 +2036,17 @@
 ing rule
-_n
+N
 ame = ar
@@ -2076,18 +2076,17 @@
 function
-_a
+A
 rn = arg
@@ -2113,18 +2113,17 @@
 g target
-_i
+I
 d = args
@@ -2242,10 +2242,16 @@
     
-%09%09
+        
 Clou
@@ -2345,16 +2345,20 @@
         
+   
+ 
 .arn(fun
@@ -2366,10 +2366,9 @@
 tion
-_a
+A
 rn)%0D
@@ -2380,16 +2380,20 @@
         
+   
+ 
 .id(targ
@@ -2398,10 +2398,9 @@
 rget
-_i
+I
 d)%0D%0A
@@ -2403,32 +2403,36 @@
 d)%0D%0A            
+   
+ 
 .build();%0D%0A%0D%0A   
@@ -2505,16 +2505,20 @@
         
+    
 .targets
@@ -2539,16 +2539,20 @@
         
+    
 .rule(ru
@@ -2549,26 +2549,25 @@
   .rule(rule
-_n
+N
 ame)%0D%0A      
@@ -2564,32 +2564,36 @@
 e)%0D%0A            
+   
+ 
 .build();%0D%0A%0D%0A   
@@ -2755,16 +2755,20 @@
         
+    
 %22Success
@@ -2837,14 +2837,17 @@
     
+   
+ 
 rule
-_n
+N
 ame)
@@ -2893,28 +2893,30 @@
 .java2.put_targets.complete%5D
+%0D%0A

Update PutTargets.java