0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Properties validation failed for resourceと怒られたら

Posted at

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は受け入れられませんと言ってくれればいいのに

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?