How to mount a specific file to AWS ECS container(fargate) with aws cdk

Viewed 762

This is how I am building a docker image, creating task definition, and deploying it to fargate cluster. My requirement is to mount a specific file from local to the container at the run time, not through the build. How can I achieve that?

task_definition = ecs.FargateTaskDefinition(
            self, f"td-{name}", task_role=task_execution_role,
            execution_role=task_execution_role,
            cpu=int(constants.task_instance_cpu)
        )

asset_docker_file = ecs.ContainerImage.from_asset(
            directory=directory,
            file=docker_file_name
        )
container = task_definition.add_container(
        id=f"cdk-deployer-{name}", container_name=name,
        image=asset_docker_file
    )
service = ecs.FargateService(
            self, f"cdk-deployer-service-{name}", cluster=cluster_name,
            service_name=name, assign_public_ip=True,
            task_definition=task_definition, security_groups=[security_group],
            desired_count=desired_count
        )
0 Answers
Related