CloudFormationのデプロイしてたらこんな感じのエラーが出ました。
Properties validation failed for resource AWSResourceMethod with message: #/AuthorizationType: #: only 1 subschema matches out of 2 #/AuthorizationType: failed validation constraint for keyword [enum]
使用していたCloudFormationテンプレートはこちらです。
AWSTemplateFormatVersion: 2010-09-09
Description: "API Gateway"
Parameters:
FunctionName:
Type: String
Resources:
Api:
Type: "AWS::ApiGateway::RestApi"
Properties:
Name: "api"
ResourceAWS:
Type: "AWS::ApiGateway::Resource"
Properties:
RestApiId: !Ref Api
ParentId: !GetAtt Api.RootResourceId
PathPart: aws
LambdaPermission:
Type: "AWS::Lambda::Permission"
Properties:
FunctionName: !Sub "${FunctionName}"
Action: "lambda:InvokeFunction"
Principal: "apigateway.amazonaws.com"
AWSResourceMethod:
Type: "AWS::ApiGateway::Method"
Properties:
RestApiId: !Ref Api
ResourceId: !Ref ResourceAWS
AuthorizationType: NONE
HttpMethod: GET
Integration:
Type: AWS
IntegrationHttpMethod: "POST"
Uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${FunctionName}/invocations"
DependsOn: "LambdaPermission"
解決する方法
なんてことはないNoneをNONEにするだけ
AWSTemplateFormatVersion: 2010-09-09
Description: "API Gateway"
Parameters:
FunctionName:
Type: String
Resources:
Api:
Type: "AWS::ApiGateway::RestApi"
Properties:
Name: "api"
ResourceAWS:
Type: "AWS::ApiGateway::Resource"
Properties:
RestApiId: !Ref Api
ParentId: !GetAtt Api.RootResourceId
PathPart: aws
LambdaPermission:
Type: "AWS::Lambda::Permission"
Properties:
FunctionName: !Sub "${FunctionName}"
Action: "lambda:InvokeFunction"
Principal: "apigateway.amazonaws.com"
AWSResourceMethod:
Type: "AWS::ApiGateway::Method"
Properties:
RestApiId: !Ref Api
ResourceId: !Ref ResourceAWS
- AuthorizationType: NONE
+ AuthorizationType: None
HttpMethod: GET
Integration:
Type: AWS
IntegrationHttpMethod: "POST"
Uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${FunctionName}/invocations"
DependsOn: "LambdaPermission"
参考にしたサイトではNONEだったのでそれで動いていた時期があったのかもしれません。
感想
それにしてもエラーメッセージが不親切すぎる。NONEは受け入れられませんと言ってくれればいいのに