'AWS API Gateway resource not getting integrated with lambda when the gateway resource is created using `fromattributes` in cdk stack

I created an API gateway resource in a stack and sending that resource to the construct as props.

While creating the method for that resource in the construct, The resource is getting created. I integrated the resource to the lambda function using the LambdaIntegration class.

During the deployment i didn't get any error. But when i try to implement the API. It is throwing

Execution failed due to configuration error: Invalid permissions on Lambda function

in Api gateway test console.

Checked the Lambda function. There the API gateway is not mapped with the Lambda function.

The API with ID YYYYY doesn’t include a resource with path XXXXX having an integration arn:aws:TTTTTTTTTTTT on GET method

Thanks in advance to help me solve the above error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source