Skip to main content
Knowledge Base

Reference Architecture: sample-app-frontend ecs - how to change desired number of tasks?

Answer

I am following the Getting Started guide in our RA deployment and I am at 03-configure-gw-pipelines.md. The guide says: > You can try out the pipeline by making a change to one of the modules. For example, try extending the number of replicas in the sample app: > > Create a new branch in the infrastructure-live repo. git checkout -B add-replica-to-sample-app. > **Open the file dev/us-east-1/dev/services/sample-app-frontend in your editor**. > Change the input variable desired_number_of_tasks to 2. > Commit the change. git commit -a. > Push the branch to GitHub and open a PR. git push add-replica-to-sample-app > Verify the plan. Make sure that the change corresponds to adding a new replica to the ECS service. > When satisfied with the plan, merge the PR into main. > Go back to the project and verify that a new build is started on the main branch. > Wait for the plan to finish. > Wait for the apply to finish. > Login to the AWS console and verify the ECS service now has 2 replicas. The reference to **Open the file dev/us-east-1/dev/services/sample-app-frontend in your editor** doesn't seem accurate as it is a directory, not a file. The directory contains a terragrunt.hcl file, nothing more. There is no input variable that I can find called "desired_number_of_tasks". In fact, I grepped my entire infrastructure-live repo and did not find a match for it. I looked into https://github.com/gruntwork-io/terraform-aws-service-catalog and found it in modules/services/ecs-service/variables.tf. The closest thing I can find to that ecs-services/variables.tf in the deployed RA repo is _envcommon/services/ecs-sample-app-frontend.hcl, but inside it I do not see a specification for the number of tasks. I am confused as to how desired_number_of_tasks is being defined and where to go about changing it. Perhaps it defaults to one and I need to add variables.tf somewhere under /dev or /stage? --- <ins datetime="2022-12-16T07:02:03Z"> <p><a href="https://support.gruntwork.io/hc/requests/109737">Tracked in ticket #109737</a></p> </ins>

It turns out that you need to edit the dev/us-east-1/dev/services/sample-app-frontend/**terragrunt.hcl** file. Under inputs you can pass in variables that override the defaults. At the bottom of the file, within the Module Parameters to pass in, you can drop this in the inputs. ``` # # Number of tasks to run # desired_number_of_tasks = 2 ```