Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.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 cloudformation 云层形成产生了;无效的模板属性或属性";错误_Amazon Cloudformation - Fatal编程技术网

Amazon cloudformation 云层形成产生了;无效的模板属性或属性";错误

Amazon cloudformation 云层形成产生了;无效的模板属性或属性";错误,amazon-cloudformation,Amazon Cloudformation,我从下面的cloudformation模板中获得“一个或多个无效的模板属性[TestLambda]”。我已经用一个在线json验证器验证了json。我试着一个接一个地删除属性,但仍然得到错误。错误消息在诊断问题时无效 有人知道问题出在哪里吗 谢谢 { "Parameters": { "DeploymentBucket": { "Type": "String", "Description": "S3 bucket name where built artifac

我从下面的cloudformation模板中获得“一个或多个无效的模板属性[TestLambda]”。我已经用一个在线json验证器验证了json。我试着一个接一个地删除属性,但仍然得到错误。错误消息在诊断问题时无效

有人知道问题出在哪里吗

谢谢

{
  "Parameters": {
    "DeploymentBucket": {
      "Type": "String",
      "Description": "S3 bucket name where built artifacts are deployed"
    },
    "ProjectVersion": {
      "Type": "String",
      "Description": "Project Version"
    },
    "DeploymentTime": {
      "Type": "String",
      "Description": "It is a timestamp value which shows the deployment time. Used to rotate sources."
    },
    "DomainName": {
      "Type": "String",
      "Description": "Domain Name to serve the application"
    },
    "CloudSearchDomain": {
      "Type": "String",
      "Description": "Endpoint Name for CloudSearch domain"
    }
  },
  "Resources": {
    "LambdaExecutionRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "Path": "/",
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "lambda.amazonaws.com",
                  "apigateway.amazonaws.com"
                ]
              },
              "Action": [
                "sts:AssumeRole"
              ]
            }
          ]
        },
        "ManagedPolicyArns": [
          "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
        ]
      }
    },
    "LambdaCustomPolicy": {
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyName": "LambdaCustomPolicy",
        "PolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": [
                "s3:ListBuckets"
              ],
              "Resource": "*"
            }
          ]
        },
        "Roles": [
          {
            "Ref": "LambdaExecutionRole"
          }
        ]
      }
    }
  },
  "TestLambda": {
    "Type": "AWS::Lambda::Function",
    "Properties": {
      "Handler": "com.serverlessbook.lambda.test.Handler",
      "Runtime": "java8",
      "Timeout": "300",
      "MemorySize": "1024",
      "Description": "Test lambda",
      "Role": {
        "Fn::GetAtt": [
          "LambdaExecutionRole",
          "Arn"
        ]
      },
      "Code": {
        "S3Bucket": {
          "Ref": "DeploymentBucket"
        },
        "S3Key": {
          "Fn::Sub": "artifacts/lambda-test/${ProjectVersion}/${DeploymentTime}.jar"
        }
      }
    }
  }
}

TestLambda
资源实际上在
resources
JSON对象之外。因此,它在AWS端的JSON验证失败,出现了意外的属性

资源中移动
TestLambda
将解决此问题

{
  "Parameters": {
    "DeploymentBucket": {
      "Type": "String",
      "Description": "S3 bucket name where built artifacts are deployed"
    },
    "ProjectVersion": {
      "Type": "String",
      "Description": "Project Version"
    },
    "DeploymentTime": {
      "Type": "String",
      "Description": "It is a timestamp value which shows the deployment time. Used to rotate sources."
    },
    "DomainName": {
      "Type": "String",
      "Description": "Domain Name to serve the application"
    },
    "CloudSearchDomain": {
      "Type": "String",
      "Description": "Endpoint Name for CloudSearch domain"
    }
  },
  "Resources": {
    "LambdaExecutionRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "Path": "/",
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "lambda.amazonaws.com",
                  "apigateway.amazonaws.com"
                ]
              },
              "Action": [
                "sts:AssumeRole"
              ]
            }
          ]
        },
        "ManagedPolicyArns": [
          "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
        ]
      }
    },
    "LambdaCustomPolicy": {
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyName": "LambdaCustomPolicy",
        "PolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": [
                "s3:ListBuckets"
              ],
              "Resource": "*"
            }
          ]
        },
        "Roles": [
          {
            "Ref": "LambdaExecutionRole"
          }
        ]
      }
    },
    "TestLambda": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Handler": "com.serverlessbook.lambda.test.Handler",
        "Runtime": "java8",
        "Timeout": "300",
        "MemorySize": "1024",
        "Description": "Test lambda",
        "Role": {
          "Fn::GetAtt": [
            "LambdaExecutionRole",
            "Arn"
          ]
        },
        "Code": {
          "S3Bucket": {
            "Ref": "DeploymentBucket"
          },
          "S3Key": {
            "Fn::Sub": "artifacts/lambda-test/${ProjectVersion}/${DeploymentTime}.jar"
          }
        }
      }
    }
  }
}

希望这有帮助

这就是问题所在。现在,我在部署过程的后面遇到了另一个失败。aws cloudformation验证模板毫无价值。