title: ECS (blue/green) deployment task definition as a resource and not as a file in codecommit repo
body: <p>I have defined an &quot;aws_ecs_task_definition&quot; resource as defined below.  And &quot;aws_ecs_task_definition&quot; has all the details required for our ECS to perform a blue/green deployment.</p>
  <pre><code>
  resource &quot;aws_ecs_task_definition&quot; &quot;ecs-task-definition&quot; {
    container_definitions    = data.template_file.ecs_task_definition_template.rendered
    family                   = &quot;${var.project_name}-${var.infra_env}-backend&quot;
    cpu                      = var.fargate_cpu
    memory                   = var.fargate_memory
    requires_compatibilities = [&quot;FARGATE&quot;]
    network_mode             = &quot;awsvpc&quot;
    execution_role_arn       = aws_iam_role.ecs_tasks_execution_role.arn
    task_role_arn            = var.task_iam_role_arn
  }
  
  data &quot;template_file&quot; &quot;ecs_task_definition_template&quot; {
    template = file(&quot;${path.module}/task-definitions/task_definition.json&quot;)
    vars = {
      task_definition_name  = &quot;${var.project_name}-${var.infra_env}-${var.container_name}&quot;
      ecs_service_name      = &quot;${var.project_name}-${var.infra_env}-service&quot;
      docker_image_url      = data.aws_ecr_repository.emc_backend_repo.repository_url
      memory                = var.fargate_memory
      docker_container_port = &quot;8000&quot;
      region                = var.region
      message               = &quot;Hi, Stack!!&quot;
    }
  </code></pre>
  <p>Problem i am facing is that my codepipleline doesn't recognize this task definition. I had to manually add a task definition file(taskdef.json) to my codecommit repository and reference in the deploy stage of my codepipeline terraform like below.</p>
  <pre><code> stage {
      name = &quot;Deploy&quot;
      action {
        name     = &quot;Deploy&quot;
        category = &quot;Deploy&quot;
        owner    = &quot;AWS&quot;
        version  = &quot;1&quot;
        //Enable ECS Blue/Green deployment
        provider        = &quot;CodeDeployToECS&quot;
        run_order       = 1
        input_artifacts = [&quot;BuildOutput&quot;]
        configuration = {
          ApplicationName     = var.code_deploy_app_name
          DeploymentGroupName = var.code_deploy_deployment_group_name
          TaskDefinitionTemplateArtifact = &quot;BuildOutput&quot;
          TaskDefinitionTemplatePath     = &quot;taskdef.json&quot;
          AppSpecTemplateArtifact = &quot;BuildOutput&quot;
          AppSpecTemplatePath     = &quot;appspec.yml&quot;
          Image1ArtifactName      = &quot;BuildOutput&quot;
          Image1ContainerName     = &quot;IMAGE1_NAME&quot;
        }
  </code></pre>
  <p>Basically i dont want add &quot;taskdef.json&quot; in my codecommit repo but instead refer the task definition i created as a resource. I want to know how can i do that and how can i let my codepipeline deploy to stage to refer the task definition from resource instead of a physical file in codecommit?</p>