serverless-apigw-binary
serverless-apigw-binary copied to clipboard
Ask for ApiGatewayRestApi directly
The function (getApiId) assumes that there exists some Output in every Stack with an OutputKey that matches 'ServiceEndpoint', but this is not always the case. (See #49, #50, #51.)
This PR modifies getApiId to request the ApiGatewayRestApi directly, rather than searching for and parsing the ServiceEndpoint. In the case where no ApiGatewayRestApi exists the plugin will have no effect, as expected.
@labichn Can you confirm this works with shared API Gateways too, when this plugin is used in an service which is using
provider:
apiGateway:
restApiId: xxxxx
restApiRootResourceId: xxxx
@EmiiKhaos I'm not familiar with that feature, but at a glance it seems to share a single ApiGatewayRestApi value among multiple stacks. If each stack has a resource named ApiGatewayRestApi this change will work.
You can confirm this yourself by looking at the stack resources on CloudFormation--if there is a resource with the key ApiGatewayRestApi, then shared gateways are also supported by this PR.
@labichn No, services using shared ApiGateway do not have ApiGatewayRestApi resource. They are just referencing an id exported by another cloud formation stack. So, no, this won't work with shared ApiGateway.
I am having this problem too.
aws cloudformation describe-stacks reports both ServiceEndpoint and ServiceEndpointWebsocket and getApiId chokes on the latter's OutputValue of 'wss://...' This fix solves the problem @maciejtreder
[ { OutputKey: 'ServiceEndpoint', OutputValue: 'https://ayo7ickqe8.execute-api.us-east-2.amazonaws.com/dev', Description: 'URL of the service endpoint' }, { OutputKey: 'ServiceEndpointWebsocket', OutputValue: 'wss://2nraf1ssae.execute-api.us-east-2.amazonaws.com/dev', Description: 'URL of the service endpoint' } ]