Invalid template property or properties upon deployment - no obvious error?

Migrating from 0.5.6 to 1.x … so far I’ve been enjoying a lot of the features of serverless.yml. I am attempting a simple deployment of some shared resources … without success. I’ve got a set of default aws credentials configured, with administrator access … sls deploy gets to the point of “Updating Stack…”, and I get this error:

  Serverless Error ---------------------------------------

     Invalid template property or properties [DwollaDb, ActivitiesDb]

Strange thing is, everything looks correct … it’s not that different from the example in the Serverless documentation, and the generated cloudFormation template looks fine:

serverless.yml:

# Resources common to all stages of irh
service: irh-resources

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

provider:
  name: aws
  runtime: nodejs4.3
  stage: resources # default stage, can be overridden with serverless deploy -s xxx
  region: us-east-1 # default region, can be overridden with serverless deploy -r xxx
functions:
resources:
  ActivitiesDb:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: irh-Activities-1.0
      AttributeDefinitions:
        - AttributeName: activityId
          AttributeType: S
      KeySchema:
        - AttributeName: activityId
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 1
        WriteCapacityUnits: 1
  DwollaDb:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: irh-Dwolla
      AttributeDefinitions:
        - AttributeName: id
          AttributeType: S
      KeySchema:
        - AttributeName: id
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 1
        WriteCapacityUnits: 1
  Outputs:
    DwollaDb:
      Description: Table name for Dwolla DynamoDB database
      Value:
        Ref: DwollaDb
    ActivitiesDb:
      Description: Table name for Activities DynamoDB database
      Value:
        Ref: ActivitiesDb

compiled-cloudformation-template.json (beautified):

{
	"AWSTemplateFormatVersion": "2010-09-09",
	"Description": "The AWS CloudFormation template for this Serverless application",
	"Resources": {
		"ServerlessDeploymentBucket": {
			"Type": "AWS::S3::Bucket"
		}
	},
	"Outputs": {
		"ServerlessDeploymentBucketName": {
			"Value": {
				"Ref": "ServerlessDeploymentBucket"
			}
		},
		"DwollaDb": {
			"Description": "Table name for Dwolla DynamoDB database",
			"Value": {
				"Ref": "DwollaDb"
			}
		},
		"ActivitiesDb": {
			"Description": "Table name for Activities DynamoDB database",
			"Value": {
				"Ref": "ActivitiesDb"
			}
		}
	},
	"ActivitiesDb": {
		"Type": "AWS::DynamoDB::Table",
		"DeletionPolicy": "Delete",
		"Properties": {
			"TableName": "irh-Activities-1.0",
			"AttributeDefinitions": [{
				"AttributeName": "activityId",
				"AttributeType": "S"
			}],
			"KeySchema": [{
				"AttributeName": "activityId",
				"KeyType": "HASH"
			}],
			"ProvisionedThroughput": {
				"ReadCapacityUnits": 1,
				"WriteCapacityUnits": 1
			}
		}
	},
	"DwollaDb": {
		"Type": "AWS::DynamoDB::Table",
		"DeletionPolicy": "Delete",
		"Properties": {
			"TableName": "irh-Dwolla",
			"AttributeDefinitions": [{
				"AttributeName": "id",
				"AttributeType": "S"
			}],
			"KeySchema": [{
				"AttributeName": "id",
				"KeyType": "HASH"
			}],
			"ProvisionedThroughput": {
				"ReadCapacityUnits": 1,
				"WriteCapacityUnits": 1
			}
		}
	}
}

Can someone see what I’m doing wrong? Thanks in advance …

DwollaDb and ActivitiesDb are appearing at the top level of your generated CFN template - that’s too damn high!

You want them to appear under the Resources heading in the template.

Under your resources in your serverless.yml file you need to create a Resources heading and then put your tables under it. I know it seems a bit strange to “double-resource” them, but what’s happening in the background is that your serverless.yml's resource object is being merged with the automatically generated CFN template, which is why you need to specify this.

Double-check the resources documentation page for an example of what I’m describing.

Ah, thank you, @rowanu … after ~2,000 lines in two serverless.yml files in a day, I got a bit blind to it all. Everything worked like a charm once you found the obvious error. :slight_smile: