Deploying and testing ECS task networking

You are now ready to deploy your changes and verify that ECS task networking is working correctly. If you run the aws cloudformation deploy command, the following should happen:

Once deployment is complete, you should verify your application is still working and once you have done this, you can browse to the ECS console, click on your ECS service, and select the current task running for the service. 

The following screenshot shows the ECS task screen:

ECS task in task networking mode

As you can see, the network mode of the task is now awsvpc, and an ENI has been dynamically allocated from the private subnet you created earlier in this chapter. If you click on the ENI ID link, you will be able to verify the security group(s) attached to the ENI, and also check that the ENI has been attached to one of your ECS container instances.

At this point, you should commit the final set of changes you made in this chapter to the ECS task networking branch, check out the master branch, and redeploy your CloudFormation stack. This will revert all of the changes made in this chapter, restoring your stack to the same state as it was at the end of the preceding chapter. This is required, given we don't want to have to upgrade to a larger instance type to accommodate the MigrateTaskDefinition resource and future auto scaling scenarios we will be testing in later chapters:

> git commit -a -m "Add ECS task networking resources"
[ecs-task-networking 7e995cb] Add ECS task networking resources
2 files changed, 37 insertions(+), 10 deletions(-)
> git checkout master
Switched to branch 'master'
> aws cloudformation deploy --template-file stack.yml --stack-name todobackend \
--parameter-overrides $(cat dev.cfg) --capabilities CAPABILITY_NAMED_IAM

Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - todobackend
Reverting the todobackend-aws repository