title: Why does CodePipeline require an `imagedefinitions.json` when ECS task definitions already have this?
body: <p>OK, so I have a CodePipeline which does a very vanilla </p>
  
  <p><code>CodeCommit -&gt; Build Docker images -&gt; CodeDeploy to ECS</code></p>
  
  <p>In the <code>buildspec.yml</code> file, AWS <a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/file-reference.html" rel="nofollow noreferrer">requires outputting <code>imagedefinitions.json</code></a> as an artifact that CodePipeline can use for mapping the container name to the ECR image URL. </p>
  
  <p>Here's the oft-cited example for how to do this in your <code>buildspec.yml</code>:</p>
  
  <p><code>printf '[{"name":"MyService","imageUri":"%s"}]' $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/myservice/app:latest &gt; imagedefinitions.json</code></p>
  
  <p>But this seems totally redundant to me. In an ECS task definition, we can have the following under our <code>containerDefinitions</code>:</p>
  
  <pre><code>"containerDefinitions": [
      {
        "name": "MyService",
        "image": "123456789.dkr.ecr.us-east-1.amazonaws.com/myservice/app:latest"
       }, 
       ...
  ]
  </code></pre>
  
  <p>Why, in order to use CodePipeline to CodeDeploy an ECS task, do we have to provide information already specified in the ECS task definition? It would be so much cleaner to remove the need for an artifact (and the S3 bucket to store said artifact) here!</p>
  
  <p>Perhaps there are some fundamentals of CodeDeploy/ECS I do not understand.</p>