3

I have tried different ways for forwarding path parameters to the VPC link endpoint.

I tried proxy integration. But I got an error.

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}/

Then I use the method from this link Illegal character in path. but It didn't work either.

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)

I have also tried to fix this issue with 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;

This is the CDK sample code.

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
)

I tried with request_parameters, but I got an error (Invalid mapping expression specified). Also tried without request_parameters so I got an error (Illegal character in the path).

It works fine without the path parameter in the URL.

So how do I fix it?

raval-64
  • 83
  • 2
  • 10

1 Answers1

2

I misunderstood it I need to add request_parameters to the method and I only added it in integration.

Got hint from here -> 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
)
raval-64
  • 83
  • 2
  • 10