awslabs / aws-solutions-constructs

The AWS Solutions Constructs Library is an open-source extension of the AWS Cloud Development Kit (AWS CDK) that provides multi-service, well-architected patterns for quickly defining solutions
https://docs.aws.amazon.com/solutions/latest/constructs/
Apache License 2.0
1.22k stars 247 forks source link

ApiGatewayToSqs: Is it possible to pass an existing API GW? #1153

Open juaoose opened 1 month ago

juaoose commented 1 month ago

This is a question:

Is it possible to provide an existing API GW to ApiGatewayToSqs, from looking at the code it looks like not? Would this be a potential feature?

biffgaut commented 1 month ago

Thanks for the suggestion.

It would be possible, but there would be challenges. Unlike some services like SQS, we use different code to create APIs based upon the context - for service integration we use the RestApi L2 construct, for Lambda integration we use the LambdaRestApi L2 construct, etc. Each construct then has significant code at the Construct level that configures resources and methods through code rather than declaratively through props.

If the apigateway-sqs construct were to receive a API created by the apigateway-lambda construct, there would be basic configuration issues that would likely cause issues. If the API were passed to a new instance of the aws-apigateway-sqs construct, then our resource names would collide.

So it's not impossible, but it would be difficult. We'll add it to our backlog to consider in the future.

In the meantime, integrating a API with 2 (or more) Lambda functions is possible with our recent aws-openapigateway-lambda construct.