title: Referencing !Ref DynamoDB table name in a AWS CloudFormation template
body: <p>I am trying to locally test passing the table name of a DynamoDB table as declared in my CloudFormation template file.</p>
  
  <p>From all the documentation I have read, I should be able to reference the the <code>TableName</code> property value of a DynamoDB resource using the <code>!Ref</code> intrinsic function. However when I test this locally the property is undefined.</p>
  
  <p>Consider the following example:</p>
  
  <pre><code>Transform: 'AWS::Serverless-2016-10-31'
  Resources:
    ServerlessFunction:
      Type: AWS::Serverless::Function
      Properties:
        Runtime: nodejs10.x
        Handler: index.handler
        Environment: 
          Variables:
            TABLE_NAME: !Ref DynamoDBTable # &lt;- returning undefined
        Events:
          GetCocktails:
            Type: Api
            Properties:
              Path: /
              Method: get
    DynamoDBTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: DynamoDBTableName
        AttributeDefinitions:
          - AttributeName: ID
            AttributeType: S
        KeySchema:
          - AttributeName: ID
            KeyType: HASH
        ProvisionedThroughput: 
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
  </code></pre>
  
  <p>I expect the <code>TABLE_NAME</code> environment variable to be <code>DynamoDBTableName</code> however it returns undefined. How do I get the template to work as expected?</p>