Skip to content

Commit

Permalink
feat(stepfunctions-tasks): allow region override in call-rest-api task (
Browse files Browse the repository at this point in the history
#33252)

### Issue # (if applicable)

#26509

### Reason for this change

AWS Step Functions has the functionality to call APIs in different regions according to the [AWS blog](https://aws.amazon.com/blogs/compute/running-cross-account-workflows-with-aws-step-functions-and-amazon-api-gateway/): "You can extend this architecture to run workflows across multiple Regions or accounts." However, CDK syntax doesn't support it. This change will help expand the functionality of CDK to be able to call APIs where the API endpoint is not in the same region as the stack it's contained in (such as calling an API in a different AWS account). 

### Description of changes

This PR implements the solution suggested by pahud, which is to add an optional region parameter to the API endpoint getter (and to props to provide it). 

Adding region to IRestApi was another option, but this would not be backwards-compatible (how would existing IRestApis determine the region?). 

Ideally, I believe some `Region` enum would be superior to type `string` for region, but I looked around and couldn't find any other examples in the codebase and besides it might introduce coupling/dependency that isn't necessary. Instead, an invalid region such as "us-north-42" is likely to simply throw an exception for invalid API endpoint, which should expose the problem to the dev.

This change supports an extra use-case of calling API endpoints in regions other than the region of the stack in which the API construct is defined. This uses AWS features of Step Functions invoking API Gateway endpoints in different regions.

### Describe any new or updated permissions being added

None

### Description of how you validated changes

Added a unit test with a hardcoded `us-west-2` in the style of other surrounding unit tests.

### Checklist
- [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
huoandre authored Feb 15, 2025
1 parent c89afe3 commit 59470c5
Show file tree
Hide file tree
Showing 18 changed files with 2,580 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 59470c5

Please sign in to comment.