aws-toolkit-eclipse icon indicating copy to clipboard operation
aws-toolkit-eclipse copied to clipboard

Unable to deploy serverless project

Open surathm opened this issue 6 years ago • 5 comments

My serverless.template file is as follows. while trying to launch I get error "Failed to deploy serverless project to AWS CloudFormation. Failed to create CloudFormation change set: [/Description] 'null' values are not allowed in templates"

{ "Type": "AWS::Serverless::Function", "Properties": { "Handler": "lambda.LambdaFormFunctionHandler", "Runtime": "Java", "CodeUri": "s3://lambda-function-bucket-us-east-1-1551523177857/LambdaForm-0.1-SNAPSHOT-shaded.jar", "Policies": [ "AmazonDynamoDBReadOnlyAccess", "AmazonS3ReadOnlyAccess" ]

}, "Resources" : { "myDynamoDBTable" : { "Type" : "AWS::DynamoDB::Table", "Properties" : { "AttributeDefinitions": [ { "AttributeName" : {"Ref" : "HashKeyElementName"}, "AttributeType" : {"Ref" : "HashKeyElementType"} } ], "KeySchema": [ { "AttributeName": {"Ref" : "HashKeyElementName"}, "KeyType": "HASH" } ], "ProvisionedThroughput" : { "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} }
} } }, "Outputs" : { "InfrastructureIP" : { "Description": "The private IP of Infrastructure",
"Value" : { "Fn::GetAtt" : [ "Infrastructure", "PrivateIp" ] } } } }

surathm avatar Mar 09 '19 07:03 surathm

It seems this template is not in the right format. The AWS::Serverless::Function resource type should be included in the Resource bracket.

zhangzhx avatar Mar 11 '19 19:03 zhangzhx

Thank you for addressing. I changed to the following still getting error.

{ "Resources" : { "MyFunction" : { "Type" : "AWS::Serverless::Function", "Properties" : "LambdaFormFunctionHandler", "CodeUri" : "..//target//LambdaForm.jar" }, "Type": "AWS::Serverless::Function", "Properties": { "Handler": "lambda.LambdaFormFunctionHandler", "Runtime": "Java", "CodeUri": "..//target//LambdaForm.jar", "Policies": [ "AmazonDynamoDBReadOnlyAccess", "AmazonS3ReadOnlyAccess" ]}, "myDynamoDBTable" : { "Type" : "AWS::DynamoDB::Table", "Properties" : { "AttributeDefinitions": [ { "AttributeName" : {"Ref" : "HashKeyElementName"}, "AttributeType" : {"Ref" : "HashKeyElementType"} } ], "KeySchema": [ { "AttributeName": {"Ref" : "HashKeyElementName"}, "KeyType": "HASH" } ] }, "ProvisionedThroughput" : { "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} }
} }, "Outputs" : { "InfrastructureIP" : { "Description": "The private IP of Infrastructure",
"Value" : { "Fn::GetAtt" : [ "Infrastructure", "PrivateIp" ] } } } }

Can you please guide to set it right.

surathmu avatar Mar 14 '19 15:03 surathmu

I've formatted the JSON code here, and it still is not a valid CloudFormation template. Also, the output Infrastructure doesn't exist. Not sure if you emit that on purpose or it was not there in the first place.

{
  "Resources": {
    "MyFunction": {
      "Type": "AWS::Serverless::Function",
      "Properties": "LambdaFormFunctionHandler",
      "CodeUri": "..//target//LambdaForm.jar"
    },
    "Type": "AWS::Serverless::Function",
    "Properties": {
      "Handler": "lambda.LambdaFormFunctionHandler",
      "Runtime": "Java",
      "CodeUri": "..//target//LambdaForm.jar",
      "Policies": [
        "AmazonDynamoDBReadOnlyAccess",
        "AmazonS3ReadOnlyAccess"
      ]
    },
    "myDynamoDBTable": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
        "AttributeDefinitions": [
          {
            "AttributeName": {
              "Ref": "HashKeyElementName"
            },
            "AttributeType": {
              "Ref": "HashKeyElementType"
            }
          }
        ],
        "KeySchema": [
          {
            "AttributeName": {
              "Ref": "HashKeyElementName"
            },
            "KeyType": "HASH"
          }
        ]
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": {
          "Ref": "ReadCapacityUnits"
        },
        "WriteCapacityUnits": {
          "Ref": "WriteCapacityUnits"
        }
      }
    }
  },
  "Outputs": {
    "InfrastructureIP": {
      "Description": "The private IP of Infrastructure",
      "Value": {
        "Fn::GetAtt": [
          "Infrastructure",
          "PrivateIp"
        ]
      }
    }
  }
}

zhangzhx avatar Mar 14 '19 17:03 zhangzhx

Could you please point out the error or give a sample template to set it right.

surathmu avatar Mar 17 '19 06:03 surathmu

เมื่อ อา. 17 มี.ค. 2562 เวลา 13:56 surathmu [email protected] เขียนว่า:

Could you please point out the error or give a sample template to set it right.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aws/aws-toolkit-eclipse/issues/135#issuecomment-473622281, or mute the thread https://github.com/notifications/unsubscribe-auth/Ao3HF3RIwglYITZGudhzyE3a48APvl4_ks5vXeb_gaJpZM4bmiR7 .

ort55555 avatar Mar 17 '19 08:03 ort55555