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

aws-stepfunctions-tasks.apigateway: cross-region RestAPI not supported #26509

Open
kiwi-33 opened this issue Jul 26, 2023 · 1 comment
Open
Labels
@aws-cdk/aws-stepfunctions-tasks effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@kiwi-33
Copy link

kiwi-33 commented Jul 26, 2023

Describe the bug

CDK builds an endpoint URL using the region of the Stack. This is a problem when I want to call a Rest API that is in a different region from the StepFunction.

Expected Behavior

From a StepFunction in region-A, I can invoke a RestAPI in region-B.

Current Behavior

API Endpoint is always the same region as the stack

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/apigateway/call-rest-api.ts#L68 (it is built without consideration for the region.)

Reproduction Steps

this is the default behavior of the CallApiGatewayRestApiEndpoint class.

Possible Solution

restApiRegion can be passed as an optional parameter and is used when building the URL in the getApiEndpoint() method.

Additional Information/Context

No response

CDK CLI Version

2.88.0

Framework Version

No response

Node.js Version

v16.20.0

OS

MacOS Darwin

Language

Typescript

Language Version

4.9.5

Other information

No response

@kiwi-33 kiwi-33 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 26, 2023
@pahud
Copy link
Contributor

pahud commented Jul 26, 2023

Yes you are right.

But looks like there's no region info in IRestApi.

export interface IRestApi extends IResourceBase {
/**
* The ID of this API Gateway RestApi.
* @attribute
*/
readonly restApiId: string;
/**
* The name of this API Gateway RestApi.
* @attribute
*/
readonly restApiName: string;
/**
* The resource ID of the root resource.
* @attribute
*/
readonly restApiRootResourceId: string;
/**
* API Gateway deployment that represents the latest changes of the API.
* This resource will be automatically updated every time the REST API model changes.
* `undefined` when no deployment is configured.
*/
readonly latestDeployment?: Deployment;
/**
* API Gateway stage that points to the latest deployment (if defined).
*/
deploymentStage: Stage;
/**
* Represents the root resource ("/") of this API. Use it to define the API model:
*
* api.root.addMethod('ANY', redirectToHomePage); // "ANY /"
* api.root.addResource('friends').addMethod('GET', getFriendsHandler); // "GET /friends"
*
*/
readonly root: IResource;
/**
* Gets the "execute-api" ARN
* @returns The "execute-api" ARN.
* @default "*" returns the execute API ARN for all methods/resources in
* this API.
* @param method The method (default `*`)
* @param path The resource path. Must start with '/' (default `*`)
* @param stage The stage (default `*`)
*/
arnForExecuteApi(method?: string, path?: string, stage?: string): string;
}

Maybe we should provide a region optional parameter for getApiEndpoint():

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jul 26, 2023
@peterwoodworth peterwoodworth added feature-request A feature should be added or improved. and removed bug This issue is a bug. labels Jul 26, 2023
@pahud pahud added p2 and removed p1 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions-tasks effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants