Skip to content
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

apigatewayv2: add arnForExecuteAPI method to HTTP API and WebSocket API construct #23301

Closed
2 tasks
tmokmss opened this issue Dec 9, 2022 · 2 comments · Fixed by #28400
Closed
2 tasks

apigatewayv2: add arnForExecuteAPI method to HTTP API and WebSocket API construct #23301

tmokmss opened this issue Dec 9, 2022 · 2 comments · Fixed by #28400
Assignees
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@tmokmss
Copy link
Contributor

tmokmss commented Dec 9, 2022

Describe the feature

RestApi construct has arnForExecuteAPI method to get ARN for its execute-api resource easily.
HttpApi and WebSocketApi should have the same method to be more consistent between apigateway and apigatewayv2 modules.

Use Case

Get ARN for execute-api of v2 API Gateways easily.

Proposed Solution

Since the formats of these ARNs are basically the same, we can copy the API of RestAPI construct. More details are in this document.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.53.0

Environment details (OS name and version, etc.)

n/a

@tmokmss tmokmss added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 9, 2022
@github-actions github-actions bot added the @aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 label Dec 9, 2022
@peterwoodworth
Copy link
Contributor

I'm not super familiar with apigateway as a service, but it doesn't seem evident to me based on the docs that this feature exists for both HTTP and WebSocket APIs. There's this page for REST APIs. A similar page exists for WebSocket APIs, however it will require additional setup which wouldn't make the same method work. I didn't find a page on invoking HTTP APIs, though I expect this method would work for HTTP APIs.

If we are able to port this to at least one of the API constructs in v2, it should be pretty simple 🙂

public arnForExecuteApi(method: string = '*', path: string = '/*', stage: string = '*') {
if (!Token.isUnresolved(path) && !path.startsWith('/')) {
throw new Error(`"path" must begin with a "/": '${path}'`);
}
if (method.toUpperCase() === 'ANY') {
method = '*';
}
return Stack.of(this).formatArn({
service: 'execute-api',
resource: this.restApiId,
arnFormat: ArnFormat.SLASH_RESOURCE_NAME,
resourceName: `${stage}/${method}${path}`,
});
}

@peterwoodworth peterwoodworth added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 10, 2022
@mergify mergify bot closed this as completed in #28400 Dec 22, 2023
mergify bot pushed a commit that referenced this issue Dec 22, 2023
…#28400)

This PR adds the arnForExecuteApi method, previously available only for REST API constructs, to both WebSocket and HTTP API constructs. 

Closes #23301 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

paulhcsun pushed a commit to paulhcsun/aws-cdk that referenced this issue Jan 5, 2024
…aws#28400)

This PR adds the arnForExecuteApi method, previously available only for REST API constructs, to both WebSocket and HTTP API constructs. 

Closes aws#23301 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants