Terraform script to specify input transformer in Cloudwatch Event Rule to get a string output.

1,748 views
Skip to first unread message

sgha...@usc.edu

unread,
Jun 25, 2018, 2:47:53 PM6/25/18
to Terraform
Hi,

I am trying to set a CloudWatch Event Rule and specify an Input Transformer in it.
This output will be passed on to a Lambda function.
I need a string output to be passed on to my Lambda function.
However I am not able to find the corresponding Terraform notation to specify the output to be string.
Following is the code snippet: 

resource "aws_cloudwatch_event_target" "event_target" {
  target_id = "SendToLambda"
  arn       = "${aws_lambda_function.user_tagger.arn}"
  input_transformer = {
   input_paths = {
       instance="$.detail.responseElements.instancesSet.items[0].instanceId",
       user="$.detail.userIdentity.arn"
       }
   input_template = 
   "{\"Instance\":<instance>,\"created by user\":<user>}"

  }
}

I needed to know the format of input_template to get the output as string.
If the {} are removed getting a syntax error.

Current Output:{"Instance":<instance>,"created by user":<user>}
Expected Output: "Instance <instance> was created by user <user>"

Please help to resolve.
Thanks,
Sayali
Message has been deleted

rahul jain

unread,
Apr 22, 2019, 7:09:43 AM4/22/19
to Terraform
try

input_template = "${jsonencode("Your ECS cluster '<clusterARN>' was stopped unexpectedly due to '<reason>'. StopCode is '<stopCode>'.")}"
Reply all
Reply to author
Forward
0 new messages