andreineculau / fl-aws

Flaws at AWS
Apache License 2.0
15 stars 0 forks source link

http proxy needs one fake integration response #6

Open andreineculau opened 7 years ago

andreineculau commented 7 years ago

When creating a AWS::ApiGateway::Method resource in cloudformation to act as a simple HTTP reverse proxy, it is still necessary to add set Properties.Integration.IntegrationResponses to the illogical [{"StatusCode": 200}].

On top of that, the source server can reply with any HTTP status code, not just 200 (but thank goodness for this illogical part, I mean!)

andreineculau commented 7 years ago

For future references, this is how the resource looks like

    Method = {
      Type: 'AWS::ApiGateway::Method',
      Properties: {
        ApiKeyRequired: undefined,
        AuthorizationType: 'NONE',
        AuthorizerId: undefined,
        HttpMethod: 'ANY',
        Integration: {
          CacheKeyParameters: [
            'method.request.path.proxy'
          ],
          CacheNamespace: undefined,
          Credentials: undefined,
          IntegrationHttpMethod: 'ANY',
          IntegrationResponses: [{
            StatusCode: '200'
          }],
          PassthroughBehavior: undefined,
          RequestParameters: {
            'integration.request.path.proxy': 'method.request.path.proxy'
          },
          RequestTemplates: undefined,
          Type: 'HTTP_PROXY',
          Uri: {'Fn::Sub': 'https://example.com/{proxy}'}
        },
        MethodResponses: undefined,
        RequestModels: undefined,
        RequestParameters: {
          'method.request.path.proxy': true
        },
        ResourceId: {Ref: 'Resource'},
        RestApiId: {Ref: 'Api'}
      }
    };