python – How to correctly define a request_parameters during integration of AWS HTTP API Gateway with AWS SQS using CDK – Stack Overflow
I have faced with a problem while writing an integration of AWS HTTP API Gateway with SQS. I use Python + awd-cdk 2.163.1. The following code:
api_gw_integration_to_sqs = aws_apigatewayv2.CfnIntegration(
self,
"SQSIntegration",
api_id=api_gw.api_id,
integration_type="AWS_PROXY",
integration_subtype="SQS-SendMessage",
payload_format_version="1.0",
credentials_arn=api_gw_to_sqs_integration_role.role_arn,
request_parameters={
"QueueUrl": queue_spike_handler.queue_url,
"MessageBody": """
{
"header":"${request.header.Authorization}",
"method":"${context.httpMethod}",
"body": "${request.body}"
}
"""
}
)
fails during deployment with the error:
Resource handler returned message: “Invalid selection expression
specified: Validation Result: warnings : [], errors : [Invalid source:
{ “header”:”${request.header.Authorization}”,
“method”:”${context.httpMethod}”, “body”: “${request.body}” }
specified for destination: MessageBody]
but, it successfully deploys with the following request_parameters values:
request_parameters={
"QueueUrl": queue_spike_handler.queue_url,
"MessageBody": """
{
"header":"${request.header.Authorization}",
"method":"${context.httpMethod}"
}
"""
}
or
request_parameters={
"QueueUrl": queue_spike_handler.queue_url,
"MessageBody": "${request.body}"
}
If anybody knows how to correct the request_parameters to get “header”, “method” and “body” together in the message?
Read more here: Source link
