aws / aws/aws-cdk

api_gateway: Creating HTTP Integration with VPC Link and NLB

Open
#26,612 7 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-apigateway bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug
No way to set URI field from within CDK

Below is a standard HttpIntegration for Use with VPC Link and NLB

```
vpc_integration = apigateway.Integration(
type=apigateway.IntegrationType.HTTP_PROXY,
integration_http_method=HttpMethods.ANY,
uri=uri,
options=apigateway.IntegrationOptions(
connection_type=apigateway.ConnectionType.VPC_LINK,
request_parameters={
"integration.request.path.proxy": "method.request.path.proxy"
},
vpc_link=link,
),
)
```

Various AWS Sources show different settings for the URI Field.

There seems to be two cases
1. Either not setting the URI
2. Setting the URI.

In cases where the URI is set it also appears necessary to append a parameter to the end usually something like

` uri=self._nlb.load_balancer_dns_name/{proxy}`

### The URI is set here but no proxy
1. https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-api-with-vpclink-cli.html
2. https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-with-private-integration.html

### Sets URI and Proxy
This CDK sample shows using proxy on the end
1. https://github.com/aws-samples/serverless-patterns/blob/main/cognito-restapi-vpclink-cdk/cdk/lib/cdk-cognito-fargate-stack.js#L190
2. Example with user setting proxy https://github.com/aws/aws-cdk/issues/10435

### Other Examples
Third party sources show using Proxy as well.

1. https://manurana.medium.com/tutorial-connecting-an-api-gateway-to-a-vpc-using-vpc-link-682a21281263

**From my own experience I can say that using proxy is required. So I cannot leave URI unset.**

However, the `nlb.load_balancer_dns_name` is a token. Try to passing it to the URI field results in

```
Invalid HTTP endpoint specified for URI (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestExcep
tion; Request ID: 0e01f5e3-4846-4315-b70f-0e7d1f5c3cd8; Proxy: null)
```
It does not matter if I try to append proxy or simply pass in the NLB name. Doesn't work.

1. So there is minimally a documenation issue with regards to proxy and setting method paramters
2. There doesn't seem to be a way to set the URI from within CDK.

### Expected Behavior

Populate the URI field

### Current Behavior

The URI field produces an error.

### Reproduction Steps

Run the attached code

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.83.1 (build 006b542)

### Framework Version

_No response_

### Node.js Version

unknown

### OS

ubuntu

### Language

Python

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the apigateway.Integration entry point and the reproduction code in the issue, then compare the linked AWS VPC Link and NLB examples with CDK's URI handling. Determine whether a tokenized NLB DNS name can populate the URI and deploy successfully; otherwise document the limitation and the required URI and proxy parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, typescript
Domain
api, backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.