title: Serverless CloudFormation template error instance of Fn::GetAtt references undefined resource
body: <p>I'm trying to setup a new repo and I keep getting the error </p>
  
  <pre><code>The CloudFormation template is invalid: Template error: instance of Fn::GetAtt 
  references undefined resource uatLambdaRole
  </code></pre>
  
  <p>in my uat stage, however the dev stage with the exact same format works fine.</p>
  
  <p>I have a resource file for each of these environments.</p>
  
  <p>dev</p>
  
  <pre><code>devLambdaRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: dev-lambda-role # The name of the role to be created in aws
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action: sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AWSLambdaFullAccess
        #Documentation states the below policy is included automatically when you add VPC configuration but it is currently bugged.
        - arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
  </code></pre>
  
  <p>uat</p>
  
  <pre><code>uatLambdaRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: uat-lambda-role # The name of the role to be created in aws
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action: sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AWSLambdaFullAccess
        #Documentation states the below policy is included automatically when you add VPC configuration but it is currently bugged.
        - arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
  </code></pre>
  
  <p>In my <code>serverless.yml</code> my role is defined as</p>
  
  <pre><code>role: ${self:custom.stage}LambdaRole
  </code></pre>
  
  <p>and the stage is set as</p>
  
  <pre><code>custom:
    stage: ${opt:stage, self:provider.stage}
  </code></pre>
  
  <p>Running <code>serverless deploy --stage dev --verbose</code> succeeds, but running <code>serverless deploy --stage uat --verbose</code> fails with the error. Can anyone see what I'm doing wrong? The uat resource was copied directly from the dev one with only the stage name change.</p>
  
  <p>Here is a screenshot of the directory the resource files are in
  <a href="https://i.stack.imgur.com/BZNm7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BZNm7.png" alt="Serverless-resources folder"></a></p>