代码之家  ›  专栏  ›  技术社区  ›  Hamed Minaee

使用import和sub psudo函数返回错误

  •  0
  • Hamed Minaee  · 技术社区  · 6 年前

      usagePlan:
    Type: AWS::ApiGateway::UsagePlan
    Properties:
      ApiStages:
      - ApiId: !ImportValue: "test-restApi-lambda-send-email-contactus-post"
        Stage: "stg1"
      Description: Customer ABC's usage plan
      Quota:
        Limit: 5000
        Period: MONTH
      Throttle:
        BurstLimit: 200
        RateLimit: 100
      UsagePlanName: Plan_ABC
    

    一切正常,代码正常工作。

      usagePlan:
    Type: AWS::ApiGateway::UsagePlan
    Properties:
      ApiStages:
      - ApiId:
        Fn::ImportValue: !Sub "${project}-restApi-lambda-send-email-contactus-post"
        Stage: "stg1"
      Description: Customer ABC's usage plan
      Quota:
        Limit: 5000
        Period: MONTH
      Throttle:
        BurstLimit: 200
        RateLimit: 100
      UsagePlanName: Plan_ABC
    

    我得到以下错误:

    An error occurred (ValidationError) when calling the CreateStack operation: [/Resources/usagePlan/Type/ApiStages/0/ApiId] 'null' values are not allowed in templates
    

    Fn::ImportValue: !Sub "${project}-restApi-lambda-send-email-contactus-post"
    

    1 回复  |  直到 6 年前
        1
  •  1
  •   spg    6 年前

    你以前找不到账单了 Fn::ImportValue

    ApiStages:
      - ApiId:
          Fn::ImportValue: !Sub "${project}-restApi-lambda-send-email-contactus-post"