5
votes

I recently started getting into the devops side of things and am currently working with Terraform and AWS ECS to setup a simple web server host my web applications.

Using my current Terraform config I can see my cluster being created with a service that has my task definition. I can't figure out how to run the tasks required to launch the webserver from Terraform. I can only see the capability to create the task definitions and services, but not run them. I am very new to both these technologies so I fear I might be missing something simple.

The setup I used is from an example I found online that I tried to follow.

TL;DR: I can create services using Terraform but can't seem to figure out how to run them.

2
do you want to create service? yes it is possible if you want to create service in other word to create container in ECSAdiii
No, I can create the service. I just don't understand how/whey tasks can be run?bos570
This is a webserver that should be up and running all the time?Mark B
@MarkB yep. Right now just looking to host a simple restful web service.bos570

2 Answers

4
votes

You need define an "aws_ecs_service" resource in Terraform and in there define how many instances of your task you want running. In the example you link, that is done in the main.tf file here.

3
votes

There is no way you can run the task from terraform except running the external script or aws-cli from the local-exec provisioner.