如何将路径参数转发到 VPC link 端点?
How to forward path parameters to the VPC link endpoint?
我尝试了将路径参数转发到 VPC link 端点的不同方法。
我试过代理集成。但是我得到一个错误。
Sending request to http://endpoint.elb.region.amazonaws.com/communities/{id}/
Execution failed due to configuration error: Illegal character in path at index 91: http://endpoint.elb.region.amazonaws.com/communities/{id}/
然后我使用这个link中的方法
Illegal character in path。
但也没用。
Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.path
.id] (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: f4d072f9-7617-4008-a78d-5fdf4c4e168d; Proxy: null)
我也尝试用 path-parameter-error 解决这个问题。
Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: true] (Service: AmazonApiGate
way; Status Code: 400; Error Code: BadRequestException;
这是CDK示例代码。
community_endpoint = communities_endpoint.add_resource('{id}')
get_community_integration = aws_apigateway.Integration(
type=aws_apigateway.IntegrationType.HTTP_PROXY,
integration_http_method='GET',
uri = 'http://'+ fargate_service.load_balancer.load_balancer_dns_name+ '/communities/{id}/',
options = aws_apigateway.IntegrationOptions(
connection_type = aws_apigateway.ConnectionType.VPC_LINK,
vpc_link= link,
request_parameters = { "integration.request.path.id" : "method.request.path.id"}
)
)
community_endpoint.add_method('GET',get_community_integration,
authorizer=authorization
)
我尝试使用 request_parameters,但出现错误(指定的映射表达式无效)。也试过没有 request_parameters 所以我得到了一个错误(路径中的非法字符)。
It works fine without the path parameter in the URL.
那我该如何解决呢?
我理解错了我需要在方法中添加request_parameters,我只在集成中添加它。
从这里得到提示 -> Hint
community_endpoint = communities_endpoint.add_resource('{id}')
get_community_integration = aws_apigateway.Integration(
type=aws_apigateway.IntegrationType.HTTP_PROXY,
integration_http_method='GET',
uri = 'http://'+ fargate_service.load_balancer.load_balancer_dns_name+ '/communities/{id}/',
options = aws_apigateway.IntegrationOptions(
connection_type = aws_apigateway.ConnectionType.VPC_LINK,
vpc_link= link,
request_parameters = { "integration.request.path.id" : "method.request.path.id"}
)
)
community_endpoint.add_method('GET',get_community_integration,
request_parameters={
"method.request.path.id": True
},
authorizer=authorization
)
我尝试了将路径参数转发到 VPC link 端点的不同方法。
我试过代理集成。但是我得到一个错误。
Sending request to http://endpoint.elb.region.amazonaws.com/communities/{id}/
Execution failed due to configuration error: Illegal character in path at index 91: http://endpoint.elb.region.amazonaws.com/communities/{id}/
然后我使用这个link中的方法 Illegal character in path。 但也没用。
Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.path
.id] (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: f4d072f9-7617-4008-a78d-5fdf4c4e168d; Proxy: null)
我也尝试用 path-parameter-error 解决这个问题。
Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: true] (Service: AmazonApiGate
way; Status Code: 400; Error Code: BadRequestException;
这是CDK示例代码。
community_endpoint = communities_endpoint.add_resource('{id}')
get_community_integration = aws_apigateway.Integration(
type=aws_apigateway.IntegrationType.HTTP_PROXY,
integration_http_method='GET',
uri = 'http://'+ fargate_service.load_balancer.load_balancer_dns_name+ '/communities/{id}/',
options = aws_apigateway.IntegrationOptions(
connection_type = aws_apigateway.ConnectionType.VPC_LINK,
vpc_link= link,
request_parameters = { "integration.request.path.id" : "method.request.path.id"}
)
)
community_endpoint.add_method('GET',get_community_integration,
authorizer=authorization
)
我尝试使用 request_parameters,但出现错误(指定的映射表达式无效)。也试过没有 request_parameters 所以我得到了一个错误(路径中的非法字符)。
It works fine without the path parameter in the URL.
那我该如何解决呢?
我理解错了我需要在方法中添加request_parameters,我只在集成中添加它。
从这里得到提示 -> Hint
community_endpoint = communities_endpoint.add_resource('{id}')
get_community_integration = aws_apigateway.Integration(
type=aws_apigateway.IntegrationType.HTTP_PROXY,
integration_http_method='GET',
uri = 'http://'+ fargate_service.load_balancer.load_balancer_dns_name+ '/communities/{id}/',
options = aws_apigateway.IntegrationOptions(
connection_type = aws_apigateway.ConnectionType.VPC_LINK,
vpc_link= link,
request_parameters = { "integration.request.path.id" : "method.request.path.id"}
)
)
community_endpoint.add_method('GET',get_community_integration,
request_parameters={
"method.request.path.id": True
},
authorizer=authorization
)