0

Facing issue related to adding custom JSON input in aws event target as we know aws didnt allow to add event pattern with scheduled expression in event rule so we have to add custom Input in target event so in that case i was using github-action to update rule target with custom Input but didnt able to update Input Json job runs fine and didnt throw any error of syntax mismatch adding code and pic for ref here.

in github-action shell job

1- rule command

aws events put-rule --name "$JOB_NAME" --schedule-expression "$JOB_SCHEDULE"

2- target command that needs to pass custom input to lambda target

aws events put-targets --rule "$JOB_NAME" --targets "Id"="1","Arn"="$LAMBDA_ARN","Input"=`{"jobName":"event_lambda_trigger"}`

another command with a different input format

aws events put-targets --rule "$JOB_NAME" --targets "Id"="$JOB_NAME","Arn"="$LAMBDA_ARN","Input"={\"jobName\":\"$JOB_NAME\"}

target rule didnt show custom input JSON instead show matched event that aws cli rule send by defaults

I tried these commands and it make rule and target but didnt update target custom JSON input I want to make target send custom JSON Input to lambda trigger. used this method also link

4
  • Also used this command with different input format JSON but didn't update above pic command: aws events put-targets --rule "$JOB_NAME" --targets "Id"="$JOB_NAME","Arn"="$LAMBDA_ARN","Input"={\"jobName\":\"$JOB_NAME\"} Commented Sep 29, 2023 at 7:05
  • See this similar issue. But, this one is using JSON as the value of --targets flag. Your use case is a bit different. Given your use case, it seems like a quotes' escaping issue. You can use shellcheck.net to fix that. Smething like aws events put-targets --rule "$JOB_NAME" --targets "\"Id\"=\"$JOB_NAME\",\"Arn\"=\"$LAMBDA_ARN\",\"Input\"=\"{\"jobName\":\"$JOB_NAME\"}\"" may work but I'm not sure. You need to test this on your side. Specifying this value as JSON as mentioned in that issue seems like a better option.
    – Azeem
    Commented Sep 29, 2023 at 11:17
  • Relevant: stackoverflow.com/questions/70582165/…
    – Azeem
    Commented Sep 29, 2023 at 11:55
  • azeem luckily i see all solutions of StackOverflow but don't know why its not updating in the end I had to use event name to use as event for my job in my case Commented Sep 30, 2023 at 20:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.