This is a stable example. It should successfully build out of the box
This example is built on Construct Libraries marked "Stable" and does not have any infrastructure prerequisites to build.
This example creates an API Gateway with proxy resources for 2 HTTP backends. This is useful for scenarios when incoming requests must be routed to one or more backend API hosts. An HTTP proxy integration enables direct interactions between clients and backends without any intervention from the API Gateway after the API method is set up.
For more information on using HTTP proxy integrations with the APIGateway check out this AWS tutorial.
For demonstration purposes this CDK example deploys a solution that routes to a couple of test HTTP APIs. The 2 test HTTP APIs are implemented using lambdas exposed through function URLs. This example can be modified though, if you prefer to use your own HTTP backend APIs. To do that you can modify the
createHTTPTestAPIsmethod in theHttpProxyApiGatewayStackclass to return a list ofProxyResourceParameterscorresponding to your own resources.
To build this example, you need to be in this example's root directory. Then run the following:
npm install -g aws-cdk
npm install
cdk synthThis will install the necessary CDK, then this example's dependencies, and then build the CloudFormation template. The resulting CloudFormation template will be in the cdk.out directory.
Run cdk deploy.
This will deploy / redeploy the Stack to AWS.
After the CDK deployment is successful, 2 URL examples will be available in the terminal console:
- One for the
HttpProxyApiGatewayStack.HelloFunctionResourceExampleoutput - One for the
HttpProxyApiGatewayStack.ByeFunctionResourceExampleoutput
At this point, you can copy each of the 2 URLs and paste them in the address bar of a browser to invoke the 2 APIs. Also note that both URLs have the same host (the DNS of the new API Gateway created).
mvn packagecompile and run testscdk lslist all stacks in the appcdk synthemits the synthesized CloudFormation templatecdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk docsopen CDK documentation