-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Description:
Invalid Response status code specified
when trying to apply CORS to SAM-created API gateway endpoints.
Steps to reproduce the issue:
- Create a SAM template w/ CORS enabled
- Deploy and have artifacts created
- Attempt to set CORS
Observed result:
Error listed above. I think the issue is that the Method Responses
that API Gateway automatically creates through the GUI when applying CORS are not being added to the endpoints that SAM creates. Therefore, when moving artifacts to another environment in a manual process (such as I have to do for my organization, we cannot use SAM to deploy Production-level artifacts) I run into the issue showed above.
Expected result:
Set endpoints correctly. Addt., why are endpoints created through SAM automatically set to use proxy-integration?
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Output of sam --version
:
0.6.0
Optional Debug logs:
Sample Template.YAML (Acct. Credentials/Role obscured for security):
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: ROLE
Globals:
Function:
Timeout: 300
Resources:
MyAPI:
Type: AWS::Serverless::Api
Properties:
Name: my-api
StageName: v1
EndpointConfiguration: EDGE
Cors:
AllowMethods: "'GET,POST,PUT,DELETE'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
MyAPIFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: my-api
CodeUri: my-api-lambda/
Handler: index.handler
Runtime: nodejs8.10
Role: arn:aws:iam::XXXXXX:role/role
Description: This lambda runs functionality.
Environment:
Variables:
HIDDEN: True
Events:
Get:
Type: Api
Properties:
Path: /my/{id}
Method: post
RestApiId:
Ref: MyAPI
Test:
Type: Api
Properties:
Path: /my/test
Method: post
RestApiId:
Ref: MyAPI
Update:
Type: Api
Properties:
Path: /my/{id}
Method: put
RestApiId:
Ref: MyAPI
Sync:
Type: Api
Properties:
Path: /my/sync/{id}
Method: get
RestApiId:
Ref: MyAPI