title: AWS CDK - Vague error while creating an AWS ECS service
body: <p>I have the following CDK code to create an ECS service. </p>
  
  <p><strong>Note:</strong> The stack is not fully configured as yet, specifically I don't have the docker image asset or any capacity attached to the cluster. My intention is to what minimum code is needed to set up the infrastructure, how different pieces of code contribute to the Cloudformation template and the defaults that are picked.</p>
  
  <p>CDK code:</p>
  
  <p><code>index.ts</code> </p>
  
  <pre class="lang-js prettyprint-override"><code>#!/usr/bin/env node
  import 'source-map-support/register';
  import cdk = require('@aws-cdk/cdk');
  import { HelloCdkStack } from '../lib/hello-cdk-stack';
  
  const app = new cdk.App();
  new HelloCdkStack(app, 'hellocdk-stack');
  
  </code></pre>
  
  <p><code>lib/hello-cdk-stack.ts</code></p>
  
  <pre class="lang-js prettyprint-override"><code>import cdk = require('@aws-cdk/cdk');
  import ecs = require('@aws-cdk/aws-ecs');
  import ec2 = require('@aws-cdk/aws-ec2');
  
  export class HelloCdkStack extends cdk.Stack {
    constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
      super(scope, id, props);
  
      const td = new ecs.Ec2TaskDefinition(scope, 'hellocdk-taskdef');
  
      const vpc = new ec2.Vpc(scope, 'hellocdk-vpc');
  
      const cluster = new ecs.Cluster(scope, 'hellocdk-cluster', {
        vpc: vpc,
      });
  
      new ecs.Ec2Service(scope, 'hellocdk-service', {
        taskDefinition: td,
        cluster: cluster,
      });
    }
  }
  </code></pre>
  
  <p>Running <code>cdk synth</code> or <code>cdk bootstrap</code> (with an <code>npm run build</code>) generates the following error -</p>
  
  <pre><code>⇒  cdk bootstrap
  
  /Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/stack.ts:65
          throw new Error(`No stack could be identified for the construct at path ${construct.node.path}`);
                ^
  Error: No stack could be identified for the construct at path hellocdk-taskrole/Resource
      at _lookup (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/stack.ts:65:15)
      at _lookup (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/stack.ts:68:14)
      at _lookup (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/stack.ts:68:14)
      at Function.of (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/stack.ts:57:12)
      at new CfnElement (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/cfn-element.ts:58:24)
      at new CfnRefElement (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/cfn-element.ts:165:1)
      at new CfnResource (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/cdk/lib/cfn-resource.ts:90:5)
      at new CfnRole (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/aws-iam/lib/iam.generated.ts:946:9)
      at new Role (/Users/nija/workplace/cdk/hello-cdk/node_modules/@aws-cdk/aws-iam/lib/role.ts:212:18)
      at new HelloCdkStack (/Users/nija/workplace/cdk/hello-cdk/lib/hello-cdk-stack.ts:10:22)
  Subprocess exited with error 1
  </code></pre>
  
  <p>Output of <code>cdk doctor</code> -</p>
  
  <pre><code>⇒  cdk doctor
  ℹ️ CDK Version: 0.35.0 (build c5e43e2)
  ℹ️ AWS environment variables:
    - AWS_ACCESS_KEY_ID = ASIA&lt;redacted&gt;
    - AWS_SECRET_ACCESS_KEY = &lt;redacted&gt;
    - AWS_SESSION_TOKEN = &lt;redacted&gt;
  ℹ️ No CDK environment variables```
  </code></pre>