如何使用 CDK python 将请求参数传递给 Api 网关的 httpintegration
How to pass request parameter to httpintegration for Api Gateway using CDK python
我在通过时遇到问题
request_parameters = {"method.request.header.User":"context.authorizer.User"}
进入 HttpIntegation:
httpintegration = _apigw.HttpIntegration(url_auth + '/logout', proxy=True, options=request_parameters({"integration.request.header.User":"$context.authorizer.User"}))
我得到了:
TypeError: 'dict' object is not callable Subprocess exited with error
1 Using: cdk python.
请参考下面的Python例子。我想需要使用 IntegrationOptions class。
CDK 及其文档不可靠,几乎没有可用的示例,有这么多缺陷。恐怕CDK还不是一般使用的级别。
cdk_api_method: aws_apigateway.Method = cdk_api_resource.add_method(
http_method=str.upper(verb),
integration=aws_apigateway.HttpIntegration(
url=url,
http_method=str.upper(verb),
proxy=True,
options=aws_apigateway.IntegrationOptions(
request_parameters=method_parameter_set['integration_request_parameters']
if 'integration_request_parameters' in method_parameter_set else None
)
)
)
"integration_request_parameters": {
"integration.request.header.{}".format(HTTP_HEADER_X_VALIDATION_CLIENT_NAME): "'{}'".format(HTTP_HEADER_X_VALIDATION_CLIENT_VALUE)
},
我在通过时遇到问题
request_parameters = {"method.request.header.User":"context.authorizer.User"}
进入 HttpIntegation:
httpintegration = _apigw.HttpIntegration(url_auth + '/logout', proxy=True, options=request_parameters({"integration.request.header.User":"$context.authorizer.User"}))
我得到了:
TypeError: 'dict' object is not callable Subprocess exited with error 1 Using: cdk python.
请参考下面的Python例子。我想需要使用 IntegrationOptions class。
CDK 及其文档不可靠,几乎没有可用的示例,有这么多缺陷。恐怕CDK还不是一般使用的级别。
cdk_api_method: aws_apigateway.Method = cdk_api_resource.add_method(
http_method=str.upper(verb),
integration=aws_apigateway.HttpIntegration(
url=url,
http_method=str.upper(verb),
proxy=True,
options=aws_apigateway.IntegrationOptions(
request_parameters=method_parameter_set['integration_request_parameters']
if 'integration_request_parameters' in method_parameter_set else None
)
)
)
"integration_request_parameters": {
"integration.request.header.{}".format(HTTP_HEADER_X_VALIDATION_CLIENT_NAME): "'{}'".format(HTTP_HEADER_X_VALIDATION_CLIENT_VALUE)
},