From AWS console, go to Services, select ECS, then click Task Definitions and Create new Task Definition.
Choose FARGATE launch type compatibility and click Next step
In the Step 2: Configure task and container definition, enter the Task Definition Name (e.g. unicorn-task-def) and select ecsTaskExecutionRole for both Task Role and Task execution role. For Network Mode, select awsvpc.
In the Task size Specify the Task memory (GB) and the Task CPU (vCPU)
As we are looking to mount the Amazon EFS volume to the container, we have to add the volume first to the task definition before adding the container.
Scroll down to Volumes section in the task definition configuration, and click Add volume button.
In the Add volume window, select volume type as EFS and provide a name for the volume (eg. wp-content). In the File system ID select the EFS volume that you created earlier, and then enable the Encryption in transit.
Finally press the Add button, now scroll up to Container definition in the task definition page.
Click Add container in the Container definitions section, enter Container name (e.g. unicorn-web-container) and Image (must be wordpress:latest - we’re using the WordPress docker official image). Memory Limits and Port mappings should be configured as on the screenshot below.
In the Environment variables section, configure parameters from the Parameter Store, that you’ve defined earlier, as on the screenshot below.
In the STORAGE AND LOGGING, select the Mount point and specify the container path /var/www/html/wp-content (this is where wordpress files that you have copied into Amazon EFS filesystem should be available for wordpress to pick them up).
In the end click the Add button for the container and Create on the task definition page.