Split-Up / Include / Reference serverless.yml file?

I ran into this problem as well. The key here seems to be dropping the includes under “resources” (lowercase) starting each included file with “Resources” (uppercase):

serverless.yml

[ ... stuff ... ]

resources:
  - ${file(./dynamo.yml)}
  - ${file(./roles.yml)}

dynamo.yml

Resources:
  DynamoTableOne:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        [ ... stuff ... ]
  DynamoTableTwo:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        [ ... stuff ... ]

roles.yml

Resources:
  MyRole:
    Type: AWS::IAM::Role
    Properties:
        [ ... stuff ... ]
  MyOtherRole:
    Type: AWS::IAM::Role
    Properties:
        [ ... stuff ... ]
4 Likes