Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services CloudFormation模板无效:模板格式错误:每个输出成员必须包含一个值对象_Amazon Web Services_Yaml_Amazon Cloudformation - Fatal编程技术网

Amazon web services CloudFormation模板无效:模板格式错误:每个输出成员必须包含一个值对象

Amazon web services CloudFormation模板无效:模板格式错误:每个输出成员必须包含一个值对象,amazon-web-services,yaml,amazon-cloudformation,Amazon Web Services,Yaml,Amazon Cloudformation,我有一个AWS IoT聊天应用程序,其UI位于React上,要进行AWS配置,我有一个使用“serverless deploy”命令执行的设置。执行时,serverless.yml将被执行,并在抛出错误时中断 CloudFormation模板无效:模板格式错误:每个输出成员必须包含一个值对象 serverless.yml代码如下所示: resources: Resources: UserTable: Type: "AWS::DynamoDB::Table" P

我有一个AWS IoT聊天应用程序,其UI位于React上,要进行AWS配置,我有一个使用“serverless deploy”命令执行的设置。执行时,serverless.yml将被执行,并在抛出错误时中断 CloudFormation模板无效:模板格式错误:每个输出成员必须包含一个值对象

serverless.yml代码如下所示:

resources:
  Resources:
    UserTable:
      Type: "AWS::DynamoDB::Table"
      Properties:
        TableName: "IotChatUsers"
        AttributeDefinitions:
          - AttributeName: identityId
            AttributeType: S
        KeySchema:
          - AttributeName: identityId
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 5
          WriteCapacityUnits: 5

    ChatTable:
      Type: "AWS::DynamoDB::Table"
      Properties:
        TableName: "IotChatChats"
        AttributeDefinitions:
          - AttributeName: name
            AttributeType: S
        KeySchema:
          - AttributeName: name
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 5
          WriteCapacityUnits: 5

    ConnectPolicy:
      Type: "AWS::IoT::Policy"
      Properties:
        PolicyName: IotChatConnectPolicy
        PolicyDocument:
          Version: "2012-10-17"
          Statement:
          - Effect: "Allow"
            Action:
              - "iot:Connect"
            Resource:
              - "*"

    PublicSubscribePolicy:
      Type: "AWS::IoT::Policy"
      Properties:
        PolicyName: IotChatPublicSubscribePolicy
        PolicyDocument:
          Version: "2012-10-17"
          Statement:
          - Effect: "Allow"
            Action:
              - "iot:Subscribe"
            Resource: { "Fn::Join" : ["",["arn:aws:iot:",{"Ref":"AWS::Region"},":",{"Ref":"AWS::AccountId"},":topicfilter/room/public/*"]] }

    PublicReceivePolicy:
      Type: "AWS::IoT::Policy"
      Properties:
        PolicyName: IotChatPublicReceivePolicy
        PolicyDocument:
          Version: "2012-10-17"
          Statement:
          - Effect: "Allow"
            Action:
              - "iot:Receive"
            Resource: { "Fn::Join" : ["",["arn:aws:iot:",{"Ref":"AWS::Region"},":",{"Ref":"AWS::AccountId"},":topic/room/public/*"]] }

    UserPool:
      Type: "AWS::Cognito::UserPool"
      Properties:
        UserPoolName: iot_chat_api_user_pool
        AutoVerifiedAttributes:
          - email
        MfaConfiguration: OFF
        Schema:
          - AttributeDataType: String
            Name: email
            Required: true

    ReactAppClient:
      Type: AWS::Cognito::UserPoolClient
      Properties:
        GenerateSecret: false
        RefreshTokenValidity: 200
        UserPoolId:
          Ref: UserPool

    IdentityPool:
      Type: "AWS::Cognito::IdentityPool"
      Properties:
        IdentityPoolName: iot_chat_api_identity_pool
        AllowUnauthenticatedIdentities: false
        CognitoIdentityProviders:
          - ClientId:
              Ref: ReactAppClient
            ProviderName:
              Fn::GetAtt: UserPool.ProviderName
        SupportedLoginProviders:
          graph.facebook.com: ${self:custom.variables.facebook_app_id}
          accounts.google.com: ${self:custom.variables.google_app_id}

    IdentityPoolAuthRole:
      Type: "AWS::IAM::Role"
      Properties:
        AssumeRolePolicyDocument:
          Version: "2012-10-17"
          Statement:
            - Effect: "Allow"
              Principal:
                Federated:
                  - "cognito-identity.amazonaws.com"
              Action:
                - "sts:AssumeRoleWithWebIdentity"
              Condition:
                StringEquals:
                  cognito-identity.amazonaws.com:aud:
                    Ref: IdentityPool
                ForAnyValue:StringLike:
                  cognito-identity.amazonaws.com:amr: authenticated
        ManagedPolicyArns:
          - arn:aws:iam::aws:policy/AWSIoTDataAccess
        Path: "/"
        Policies:
          - PolicyName: iot-chat-invoke-api-gateway
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Action:
                    - execute-api:Invoke
                  Resource: { "Fn::Join" : ["", ["arn:aws:execute-api:",{"Ref":"AWS::Region"},":",{"Ref":"AWS::AccountId"},":",{"Ref":"ApiGatewayRestApi"},"/*"]] }

    IdentityPoolRoleAttachment:
      Type: AWS::Cognito::IdentityPoolRoleAttachment
      Properties:
        IdentityPoolId:
          Ref: IdentityPool
        Roles:
          authenticated:
            Fn::GetAtt:
              - IdentityPoolAuthRole
              - Arn

    ConfirmUserInvocationPermission:
      Type: AWS::Lambda::Permission
      Properties:
        Action: lambda:InvokeFunction
        FunctionName:
          Fn::GetAtt: AutoConfirmUserLambdaFunction.Arn
        Principal: cognito-idp.amazonaws.com
        SourceArn:
          Fn::GetAtt: UserPool.Arn

  Outputs:
    UserPoolId:
      Description: "The ID of the user pool that is created."
      Value:
        Ref: UserPool

    ReactAppClientId:
      Description: "The ID of the user pool react app client id."
      Value:
        Ref: ReactAppClient

    IdentityPoolId:
      Description: "The ID of the identity pool that is created."
      Value:
        Ref: IdentityPool

    AutoConfirmUserFnArn:
      Description: "The ARN of the Auto Confirm User Lambda function"
      Value:
        Fn::GetAtt:
          - AutoConfirmUserLambdaFunction
          - Arn

    FacebookAppId:
      Description: "Facebook App Id"
      Value: ${self:custom.variables.facebook_app_id}

    GoogleAppId:
      Description: "Google App Id"
      Value: ${self:custom.variables.google_app_id}
我需要一些洞察力来找出serverless.yml的错误,它抛出了这个验证错误

Environment Information -----------------------------
     OS:                     win32
     Node Version:           8.9.1
     Serverless Version:     1.25.0
更新:

在解析YAML时,下面是输出节点的结果:

"Outputs": {
      "IdentityPoolId": {
        "Description": "The ID of the identity pool that is created.", 
        "Value": {
          "Ref": "IdentityPool"
        }
      }, 
      "FacebookAppId": {
        "Description": "Facebook App Id", 
        "Value": "${self:custom.variables.facebook_app_id}"
      }, 
      "ReactAppClientId": {
        "Description": "The ID of the user pool react app client id.", 
        "Value": {
          "Ref": "ReactAppClient"
        }
      }, 
      "GoogleAppId": {
        "Description": "Google App Id", 
        "Value": "${self:custom.variables.google_app_id}"
      }, 
      "UserPoolId": {
        "Description": "The ID of the user pool that is created.", 
        "Value": {
          "Ref": "UserPool"
        }
      }, 
      "AutoConfirmUserFnArn": {
        "Description": "The ARN of the Auto Confirm User Lambda function", 
        "Value": {
          "Fn::GetAtt": [
            "AutoConfirmUserLambdaFunction", 
            "Arn"
          ]
        }
      }
    }
更新2:


这就是完整应用程序的来源:

CloudFormation通常提供模糊的或难以跟踪的错误,并且从不报告带有行号的错误,就像许多解释器/编译器/解析器一样。因此,追踪他们通常是一个反复试验的过程

在您的例子中,错误消息只提到错误在模板的
输出部分,但没有提到哪个值是问题所在。该部分中有6个值

故障排除的一个好方法是一次删除一个或两个项目,然后重新运行模板。由于输出值只是输出,所以此模板不需要它们,而是在稍后的创建过程中将数据公开给其他模板。只需按照建议删除它们,并使用此技术将字段与值中的错误隔离

良好的健全性检查是删除整个
输出
部分,并确认模板的重置按预期创建

一旦找到有问题的字段,您就需要找到主要问题:
每个输出成员必须包含一个值对象

若要解决此问题,请跟踪被引用的对象,并跟踪回源资源或资源属性。由于某些原因,这些引用没有引用有效的对象


我将注意到,在您的评论中,您确定了两个字段,这两个字段都导致了错误。两者似乎都以
self:custom.variables.google\u app\u id
的形式使用变量引用-这些值解析不正确。如上所述检查其来源。我怀疑它们没有被正确解析。我不认为该构造是有效的CloudFormation语法。

如果从输出块中删除AutoConfigrmUserFnarn,是否会出错?但这是用户对Lambda函数的确认,为什么要删除它?只是为了测试。看看这是否是错误的来源。我会逐个删除,一次删除一个,以隔离错误消息的来源。其中一个是坏的,我试过了,但是没有用,如果你删除了整个输出部分,你仍然会得到一个错误?