Skip to content

Ask for ApiGatewayRestApi directly #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ask for ApiGatewayRestApi directly #52

wants to merge 2 commits into from

Conversation

labichn
Copy link

@labichn labichn commented Apr 26, 2019

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.

@QuingKhaos
Copy link

@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

@labichn
Copy link
Author

labichn commented May 6, 2019

@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.

@hakimio
Copy link

hakimio commented Oct 2, 2019

@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.

@KenHuffman
Copy link

KenHuffman commented Aug 18, 2020

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'
}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants