To enable AWS_IAM auth and CORS, I made my sam template as follows.
However, I got an error saying
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ListFunction] is invalid. Event with id [ListFunctionCors] is invalid. Unable to set Authorizer [NONE] on API method [options] for path [/list] because the related API does not define any Authorizers.
What is wrong here?
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
ListApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
DefaultAuthorizer: AWS_IAM
Cors:
AllowMethods: "'*'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
ListFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: app_src/
Handler: app.lambda_handler
Runtime: python3.7
Events:
ListFunction:
Type: Api
Properties:
RestApiId: !Ref ListApi
Path: /list
Method: GET
ListFunctionCors:
Type: Api
Properties:
RestApiId: !Ref ListApi
Path: /list
Method: OPTIONS
Auth:
Authorizer: 'NONE'