title: Create a cloudwatch event rule target to a lambda function with different inputs in Terraform
body: <p>I created a CloudWatch event rule to trigger a lambda function to run in schedule. Howerver, I want the rule run with 2 different input values.</p>
  <p>E.g: input1 is:
  {&quot;namequery&quot;: &quot;top-10-ip&quot;, &quot;s3bucket&quot;: &quot;stg-log&quot;, &quot;query&quot;: &quot;SELECT client_ip from ip_tables limit 10&quot;}</p>
  <p>and input2 is: {&quot;namequery&quot;: &quot;countError&quot;, &quot;s3bucket&quot;: &quot;stg-log&quot;, &quot;query&quot;: &quot;SELECT error from error_logs&quot;}</p>
  <p>My expected result is like this image:
  <a href="https://i.stack.imgur.com/KuSBT.png" rel="nofollow noreferrer">expected result</a></p>
  <p>My Terraform code:</p>
  <pre><code>resource &quot;aws_cloudwatch_event_rule&quot; &quot;athena_sender&quot; {
    name                = &quot;${var.app_name}-${var.env_name}-lambda-athena-sender&quot;
    description         = &quot;${var.app_name}-${var.env_name} athena sender&quot;
    schedule_expression = var.options_athena_sender[&quot;schedule_expression&quot;]
  }
  
  resource &quot;aws_cloudwatch_event_target&quot; &quot;athena_sender1&quot; {
    rule      = aws_cloudwatch_event_rule.athena_sender.name
    target_id = aws_lambda_function.athena_sender_function.id
    arn       = aws_lambda_function.athena_sender_function.arn
    input     = &lt;&lt;JSON
      {
        &quot;namequery&quot;: &quot;${var.options_athena_sender[&quot;namequery1&quot;]}&quot;,
        &quot;s3bucket&quot;: &quot;${aws_s3_bucket.s3_logs.bucket}&quot;,
        &quot;query&quot;: &quot;${var.options_athena_sender[&quot;query1&quot;]}&quot;
      }
    JSON
  }
  
  resource &quot;aws_cloudwatch_event_target&quot; &quot;athena_sender2&quot; {
    rule      = aws_cloudwatch_event_rule.athena_sender.name
    target_id = aws_lambda_function.athena_sender_function.id
    arn       = aws_lambda_function.athena_sender_function.arn
    input     = &lt;&lt;JSON
      {
        &quot;namequery&quot;: &quot;${var.options_athena_sender[&quot;namequery2&quot;]}&quot;,
        &quot;s3bucket&quot;: &quot;${aws_s3_bucket.s3_logs.bucket}&quot;,
        &quot;query&quot;: &quot;${var.options_athena_sender[&quot;query2&quot;]}&quot;
      }
    JSON
  
    depends_on = [aws_cloudwatch_event_target.athena_sender1]  // delay creation of the second athena sender CW event to prevent ConcurrentModificationException
  }
  </code></pre>
  <p>However, it sounds like Terraform do not recognize the differences and it only create only 1 target.</p>
  <p>Hope that anyone can help me, thank you so much!</p>