title: How to use ECS task role credentials with AWS SDK in Angular4
body: <p>I am using the aws-sdk for JS / nodejs to upload files in Angular4 to a S3 bucket.</p>
  
  <p>The <strong>upload works fine without any issues</strong> if I specify my credentials (accesskeyId, accesskey) when creating the S3 client object.</p>
  
  <h1>Issue</h1>
  
  <p>I am trying to use <strong>ECSCredentials</strong> because I do not want to expose my accesskeys anywhere in my code.</p>
  
  <p>My application is running in a <strong>ECS Container Instance</strong> and is executed with an <strong>ECS Task</strong>.</p>
  
  <p>I have created an ECS Task role in IAM and attached it to the Task via the Task Role inside my container definitions. (I followed this documentation <a href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html" rel="nofollow noreferrer">http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html</a>)</p>
  
  <p>Once the task is running, I am able to log into the container (via ssh) and check if the permissions is working via "curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"</p>
  
  <p><strong>This works 100% and outputs my credentials just like the example.</strong></p>
  
  <p>However, I am having a very hard time trying to get this to work with aws-sdk.</p>
  
  <p>In my Angular4 component, I add the SDK like so :</p>
  
  <pre><code>import { ECSCredentials, S3 } from 'aws-sdk';
  </code></pre>
  
  <p>I create my S3 object like so :</p>
  
  <pre><code>private _s3ClientConfig: S3.ClientConfiguration;
  private _s3: S3;
  </code></pre>
  
  <p>and then create the instance like so :</p>
  
  <pre><code>this._s3ClientConfig = {
  credentials: new ECSCredentials({
    httpOptions: { timeout: 5000 },
    maxRetries: 10,
    retryDelayOptions: { base: 200 }}),
  region: this._awsConfig.s3BucketRegion,
  sslEnabled: true
  };
  
  this._s3 = new S3(this._s3ClientConfig);
  </code></pre>
  
  <p>When I do this, I get the error :</p>
  
  <pre><code>ECSCredentials is not a constructor
  </code></pre>
  
  <p>I have also tried omitting the "credentials" part, however, then I get the error :</p>
  
  <pre><code> Missing credentials in config
  </code></pre>
  
  <p>I have also tried creating the S3 client options as type S3.ClientConfiguration or just a normal object, same error persists.</p>
  
  <p>I have followed instructions on another stack overflow question here : <a href="https://stackoverflow.com/questions/45634775/how-to-use-ecs-credentials-with-aws-js-sdk">How to use ECS credentials with AWS JS SDK</a> , however, no luck, same problems and errors.</p>