Different task definition templates AWS and Terraform

Hello everyone!
I use AWS Code Pipeline to install new versions of ECS services.
For correct operation, a task definition is required.
I also use terraform to deploy infrastructure, which also requires a task definition template.
But these templates are different, because the template for CodePipeline contains all sections (including volumes), and the terraform template contains only the description of the containers.
This creates a problem - I cannot have the same files with task definitions. The number of applications is more than 40 and every time I change the task definition (for example, add secrets and variables) I have to do this twice.
How can I use one task definition?
If this is not possible, could you please add it

Yes, it is occurring in code deployment step.
can we add it task def incrementally without overwrite it ?