title: Getting cloudformation error: Unresolved resource dependencies [XXXX] in the Resources block of the template
body: <p>I have turned my original cloudformation stack template into multiple child templates which I then call from a master template. One of the child templates possesses the following snippet, for which I'm getting the error:</p>
  
  <p><code>An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: Unresolved resource dependencies [GeneralPurposeContainerRole] in the Resources block of the template</code></p>
  
  <p><strong>BatchResourcesStack</strong> (child stack):</p>
  
  <pre><code>---
  AWSTemplateFormatVersion: '2010-09-09'
  Description: batch resources stack.
  Parameters:
    GPCEName:
      Type: String
    GPCEMaxVcpus:
      Type: Number
      Description: Max number of VCPUs for entire cluster, there are caveats to this
    GPCEMinVcpus:
      Type: Number
      Description: Min number of VCPUs for entire cluster, there are caveats to this
    GPCEDesiredVcpus:
      Type: Number
      Description: Desired number of VCPUs for entire cluster, there are caveats to this
    GPCEVpcId:
      Type: String
    GPCESubnetAZ1:
      Type: String
    GPCEAmi:
      Type: String
    GPCEInstanceTypes:
      Type: CommaDelimitedList
    GPCESSHKeyPair:
      Type: String
    StackUID:
      Type: String
    SecurityGroup:
      Type: AWS::EC2::SecurityGroup
    Subnet:
      Type: AWS::EC2::Subnet
  
  Resources:
    BatchServiceRole:
      Type: AWS::IAM::Role
      Properties:
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Principal:
              Service: batch.amazonaws.com
            Action: sts:AssumeRole
        ManagedPolicyArns:
        - arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole
  
    IamInstanceProfile:
      Type: AWS::IAM::InstanceProfile
      Properties:
        Roles:
        - !Ref 'EcsInstanceRole'
  
    EcsInstanceRole:
      Type: AWS::IAM::Role
      Properties:
        AssumeRolePolicyDocument:
          Version: '2008-10-17'
          Statement:
          - Sid: ''
            Effect: Allow
            Principal:
              Service: ec2.amazonaws.com
            Action: sts:AssumeRole
        ManagedPolicyArns:
        - arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role
  
    GeneralPurposeContainerRole:
      Type: "AWS::IAM::Role"
      Properties:
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Principal:
                Service:
                  - ecs-tasks.amazonaws.com
              Action:
              - sts:AssumeRole
        Path: '/'
        Policies:
          - PolicyName: ContainerS3Access
            PolicyDocument:
              Statement:
              - Effect: Allow
                Action:
                - s3:PutObject
                - s3:GetObject
                - s3:DeleteObject
                - s3:List*
                Resource:
                  # TODO: Make these non psychcore-specific
                - arn:aws:s3:::pipeline-validation/*
                - arn:aws:s3:::wgs-pipeline-vqsr-test/*
                - arn:aws:s3:::test-references/*
                - arn:aws:s3:::psychcore-pipelines/output/*
                - arn:aws:s3:::psychcore-pipelines/validation/samples/*
                - arn:aws:s3:::psychcore-data/reference_indexs/*
                - arn:aws:s3:::psychcore-pipelines
                - arn:aws:s3:::psychcore-pipelines
                - arn:aws:s3:::psychcore-data
                - arn:aws:s3:::*
              - Effect: Allow
                Action:
                - s3:List*
                - s3:ListMultipartUploadParts
                - s3:AbortMultipartUpload
                - s3:ListBucketMultipartUploads
                Resource:
                - arn:aws:s3:::pipeline-validation
                - arn:aws:s3:::wgs-pipeline-vqsr-test
                - arn:aws:s3:::test-references
                - arn:aws:s3:::psychcore-pipelines/output/
                - arn:aws:s3:::psychcore-pipelines/validation/samples/
                - arn:aws:s3:::psychcore-data/reference_indexs/
                - arn:aws:s3:::psychcore-pipelines
                - arn:aws:s3:::psychcore-pipelines
                - arn:aws:s3:::psychcore-data
                - arn:aws:s3:::*
  
    GeneralPurposeComputeEnvironment:
      Type: "AWS::Batch::ComputeEnvironment"
      Properties:
        Type: MANAGED
        ComputeEnvironmentName: !Join
            - '-'
            - - !Ref GPCEName
              - !Ref StackUID
        ComputeResources:
          MinvCpus:
            Ref: GPCEMinVcpus
          MaxvCpus:
            Ref: GPCEMaxVcpus
          DesiredvCpus:
            Ref: GPCEDesiredVcpus
          SecurityGroupIds:
            - Ref: SecurityGroup
          Subnets:
            - Ref: Subnet
          Type: 'EC2'
          ImageId:
            Ref: GPCEAmi
          InstanceRole:
            Ref: IamInstanceProfile
          InstanceTypes:
            Ref: GPCEInstanceTypes
          Ec2KeyPair:
            Ref: GPCESSHKeyPair
          Tags:
            Key: Name
            Value: "VariantCallingBatchComputeEnvironment"
        ServiceRole:
          Ref: BatchServiceRole
        State: ENABLED
      DependsOn:
        - SecurityGroup
        - Subnet
        - IamInstanceProfile
        - BatchServiceRole
  
    GeneralPurposeQueue:
      Type: "AWS::Batch::JobQueue"
      Properties:
        ComputeEnvironmentOrder:
          - Order: 1
            ComputeEnvironment: !Ref GeneralPurposeComputeEnvironment
        Priority: 1
        State: ENABLED
        JobQueueName: !Join
            - '-'
            - - "GeneralPurposeQueue"
              - !Ref StackUID
      DependsOn:
        - GeneralPurposeComputeEnvironment
        - BatchServiceRole
  </code></pre>
  
  <p><strong>Parent.yaml</strong> (contains parts relevant to above child stack):</p>
  
  <pre><code>---
  AWSTemplateFormatVersion: "2010-09-09"
  Description: "Master template for wgs-pipeline. Calls to other stack templates."
  Parameters:  
    GPCEName:
      Default: 'GeneralPurposeVariantCallingCE'
      Type: String
    GPCEMaxVcpus:
      Default: 128
      Type: Number
      Description: Max number of VCPUs for entire cluster, there are caveats to this
    GPCEMinVcpus:
      Default: 0
      Type: Number
      Description: Min number of VCPUs for entire cluster, there are caveats to this
    GPCEDesiredVcpus:
      Default: 0
      Type: Number
      Description: Desired number of VCPUs for entire cluster, there are caveats to this
    GPCEVpcId:
      Type: String
    GPCESubnetAZ1:
      Default: 'us-east-1a'
      Type: String
    GPCEAmi:
      Default: "ami-ce6cdfb4"
      Type: String
    GPCEInstanceTypes:
      Default: "i3.xlarge, i3.2xlarge, i3.4xlarge, i3.8xlarge, i3.16xlarge"
      Type: CommaDelimitedList
    GPCESSHKeyPair:
      Type: String
    StackUID:
      Default: "1234"
      Type: String
  
  Resources:
    Subnet:
      Type: AWS::EC2::Subnet
      Properties:
        CidrBlock: 10.0.0.0/24
        VpcId: !Ref 'VPC'
        AvailabilityZone: !Ref GPCESubnetAZ1
        MapPublicIpOnLaunch: 'True'
    SecurityGroup:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupDescription: EC2 Security Group for instances launched in the VPC by Batch
        VpcId: !Ref 'VPC'
    BatchResourcesStack:
      Type: AWS::CloudFormation::Stack
      Properties:
        Parameters:
          GPCEName:
            Ref: GPCEName
          GPCEMaxVcpus:
            Ref: GPCEMaxVcpus
          GPCEMinVcpus:
            Ref: GPCEMinVcpus
          GPCEDesiredVcpus:
            Ref: GPCEDesiredVcpus
          GPCEVpcId:
            Ref: GPCEVpcId
          GPCESubnetAZ1:
            Ref: GPCESubnetAZ1 
          GPCEAmi:
            Ref: GPCEAmi
          GPCEInstanceTypes:
            Ref: GPCEInstanceTypes
          GPCESSHKeyPair:
            Ref: GPCESSHKeyPair
          StackUID:
            Ref: StackUID
          SecurityGroup:
            Ref: SecurityGroup
          Subnet:
            Ref: Subnet
        TemplateURL: https://s3.amazonaws.com/CFNTemplate/batch_resources.stack.yaml
        Timeout: "100"
  </code></pre>
  
  <p>I don't understand what the error is specifically pointing to. I put the entire <strong>Batch-child.yaml</strong> file through a YAML validator and it passed, so it shouldn't be from a formatting/indention error per se. Also, the GeneralPurposeContainerRole resource does not get referenced to anywhere else in the template, nor even in the parent stack template.</p>