Creating an ECS service

We have created an ECS cluster and configured an ECS task definition that includes a single container running Nginx with an appropriate port mapping configuration to expose the Nginx web server to the outside world.

We now need to define an ECS service, which will configure ECS to deploy one or more instances of our ECS task definition to our ECS cluster. ECS services deploy a given ECS task definition to a given ECS cluster, allowing you to configure how many instances (ECS tasks) of the referenced ECS task definition you would like to run, and controlling more advanced features, such as load balancer integration and rolling updates of your application.

To create a new ECS service, complete the following steps:

  1. In the ECS console, select Clusters from the left and click on the test-cluster you created earlier in this chapter:
Selecting an ECS Cluster to Create an ECS Service
  1. In the Cluster details page, select the Services tab and click on Create to create a new service.
  2. On the Configure service screen, configure the following settings and once complete click the Next step button. Notice that we reference both the task definition and ECS cluster we created earlier in this chapter:
    • Launch type: EC2
    • Task Definition: simple-web:1
    • Cluster: test-cluster
    • Service name: simple-web
    • Number of tasks: 1
  3. The remainder of the ECS service configuration settings are optional. Keep on clicking Next step until you reach the Review screen, where you can review your settings and click Create Service to complete creation of the ECS service.
  4. The Launch Status screen will now appear and once your service has been created, click on the View Service button.
  5. The Service details screen will now appear for your new ECS service, and you should see a single ECS task in a RUNNING state, meaning the Nginx container associated with the simple-web ECS task definition was successfully launched:
Completing Creation of a New ECS Service

At this stage, you should now be able to browse to your newly deployed Nginx web server, which you can verify by browsing to the public IP address of the ECS container instance you created earlier as part of your ECS cluster. If everything is working as expected, you should be presented with the default Welcome to nginx page, as shown in the following screenshot:

Browsing to the Nginx Web Server