title: AWS Fargate deploy: "Invalid action configuration The AWS ECS container ***** does not exist"
body: <p>I am using terraform to provision the resources required. </p>
  
  <p>I have a terraform codepipeline <code>resource</code> and the <code>Production</code> <code>stage</code> reads the <code>imagedefinitions.json</code> file to know which images to deploy:</p>
  
  <pre><code>resource "aws_codepipeline" "pipeline" {
    stage {
      name = "Build"
      action {
        name             = "Build"
        category         = "Build"
        owner            = "AWS"
        provider         = "CodeBuild"
        version          = "1"
        input_artifacts  = ["source"]
        output_artifacts = ["imagedefinitions"]
        configuration {
          ProjectName = "${var.project_prefix}-codebuild"
        }
      }
    }
   stage {
      name = "Production"
      action {
        name            = "Deploy"
        category        = "Deploy"
        owner           = "AWS"
        provider        = "ECS"
        input_artifacts = ["imagedefinitions"]
        version         = "1"
        configuration {
          ClusterName = "${var.ecs_cluster_name}"
          ServiceName = "${var.ecs_service_name}"
          FileName    = "imagedefinitions.json"
        }
      }
    }
  </code></pre>
  
  <p>The <code>imagedefinitions.json</code> file is built during the build phase, from <code>buildspec.yml</code>:</p>
  
  <pre><code>build:
    commands:
      - echo Build started on 'date'
      - echo Building the Docker image...
      - docker build -t $REPOSITORY_URI:latest .
      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on 'date'
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:latest
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - echo Writing image definitions file...
      - printf '[{"name":"docker-image-name","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG &gt; imagedefinitions.json  
  </code></pre>
  
  <p>I am not sure what the name of the image should be in this line: </p>
  
  <blockquote>
    <ul>
    <li>printf '[{"name":"docker-image-name","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json  </li>
    </ul>
  </blockquote>
  
  <p>The error I get repeats the "name" value from this line:</p>
  
  <blockquote>
    <p>"Invalid action configuration The AWS ECS container docker-image-name does not exist"</p>
  </blockquote>
  
  <p>What is the name I should have in here?</p>