I've set up an integration on my API Gateway V2 (HTTP) to send a message to my SQS FIFO queue. I need to set the MessageGroupId to use two properties that exist on the request body. The requests sent to API Gateway will be POST requests with a JSON body. I want to use the $request.body.orgKey
and $request.body.entityType
to create my MessageGroupId but I've been unsuccessful.
When sending requests to the API Gateway with MessageGroupId of the RequestParameters set to MessageGroupId: '${request.body.orgKey}${request.body.entityType}'
, the request fails and the logs show the following error message:
"Unable to resolve property MessageGroupId from source ${request.body.orgKey}${request.body.entityType}. Please make sure that the request to API Gateway contains all the necessary fields specified in request parameters."
When I use just one property, e.g. ${request.body.orgKey}
, the message is enqueued successfully.
My CloudFormation object:
APIGatwaySQSIntegration: {
Type: 'AWS::ApiGatewayV2::Integration',
Properties: {
ApiId: {
Ref: 'ApiGateway'
},
CredentialsArn: '${self:provider.iam.role}',
IntegrationType: 'AWS_PROXY',
IntegrationSubtype: 'SQS-SendMessage',
PayloadFormatVersion: '1.0',
RequestParameters: {
QueueUrl: {
Ref: 'webhooksQueue',
},
MessageBody: '$request.body',
MessageDeduplicationId: '$request.body.eventId',
// Does not work
MessageGroupId: '${request.body.orgKey}${request.body.entityType}',
// Works but not what I need
// MessageGroupId: '$request.body.orgKey',
}
}
},```
Ugh... I wasn't including entityType
in the request body... The cloudformation template was fine