Skip to content

Manually created CORS-enabled Proxy API leads to different config in SAM #807

@alex-harvey-z3q

Description

@alex-harvey-z3q

Description:

When deploying an implicit API with SAM and then doing what I take to be the same steps in API Gateway in the AWS Console, I end up with a different configuration. To be sure, I'm not sure if this is a support request or a behaviour that needs better documentation or a bug.

Steps to reproduce the issue:

1/ In Console, create a Proxy resource. Steps: Go to API Gateway => Create API => (Name=MyAPI, Endpoint Type=Edge Optimized). Then: Actions => Create Resource => (Configure as Proxy resource, leave Enable API Gateway CORS UNchecked) => Create Resource. Then: Lambda Function=Some Lambda Function. Then: Save. Then: Select the /{proxy+} resource => Actions => Enable CORS => (Gateway Responses for MyAPI API=Default 4XX,Default 5XX) => Enable CORS and replace existing CORS headers.

2/ In a SAM template:

Globals:
  Api:
    EndpointConfiguration: EDGE
    Cors:
      AllowMethods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'"
      AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
      AllowOrigin: "'*'"
Resources:
  ChatAPIFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: my-api/
      Handler: index.handler
      Runtime: nodejs8.10
      Policies: AmazonS3ReadOnlyAccess
      Events:
        ProxyApiGreedy:
          Type: Api
          Properties:
            Path: /{proxy+}
            Method: ANY

Observed result:

For the manually create API I see in the Method Response "Models: application/json => Empty" as shown here:

screen shot 2019-02-11 at 12 30 04 am

For the SAM-created API I don't see the Models:

screen shot 2019-02-11 at 12 33 27 am

Expected result:

I expected both these approaches to result in the same config, and if not, I expected to be able to somehow use SAM to generate the same config I generated manually.

Additional info:

This may be related to #640

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions