I hope the title makes sense. What I am trying to do is create the AWS cdk code to have an AWS eventbridge rule trigger a lambda function with static input. What the input needs to look like is this
"""{
"resource": "/{proxy+}",
"path": "/jobs/sendRepoJob",
"httpMethod": "POST",
"requestContext": "{}",
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"body": "{\"Configs\":{\"_url\":\"<some_url>",\"name\":\"<some_name>\"},\"Configs2\":{\"_url\":\"<some_url>",\"name\":\"<some_name>\"}}"
"isBase64Encoded": null
}"""
Basically, I need the json string as the body in the static input for the eventbridge rule. However, when I try to create the rule with AWS CDK, the events.CfnRule.TargetProperty
object takes a json string as input as seen from the documentation https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_events/CfnRule.html#aws_cdk.aws_events.CfnRule.TargetProperty
My code for creating event in AWS CDK is shown below.
rule = events.CfnRule(self,
"InvokeApiRule",
description="test",
schedule_expression="rate(2 minutes)",
state="ENABLED",
role_arn=role.role_arn,
targets=[events.CfnRule.TargetProperty(
arn="<lambda_arn>",
id="<someID>",
dead_letter_config=events.CfnRule.DeadLetterConfigProperty(
arn="<dlq_arn>"
),
input = tmp_input
)])
When I try making the json string, in the script for "tmp_input", it automatically converts it to json when creating the stack. I need it to be a string, and stay a string as I showed above.
Anyone know how to do this?
source https://stackoverflow.com/questions/75892537/how-to-put-a-string-of-json-string-representation-into-a-json-string-aws-eventb
Comments
Post a Comment