![](https://www.devopsschool.com/blog/wp-content/uploads/2019/10/Terraform-variable-Number-Type-Explained.png)
In this example, the instance_count
variable is defined with a type of number
, and it is given a default value of 1
. The AWS provider is then configured to use the us-west-2
region.
The aws_instance
resource is used to launch Amazon EC2 instances. The count
argument is set to the value of the instance_count
variable, which means that Terraform will launch instance_count
number of EC2 instances.
You can change the value of instance_count
by modifying the default value in the variable definition, or you can specify a different value when you run Terraform by using the -var
flag. For example, if you want to launch 3 instances, you can run the following command:
$ terraform apply -var ‘instance_count=3’
![loading](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/gallery-page-loader.gif)
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Basic Tutorial with Demo by Piyush 2020
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Fundamental Tutorials by Harish in 2020
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Fundamental Tutorial By Guru in 2020 Part-1
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Fundamental Tutorial By Guru in 2020 Part-2
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Fundamental Tutorial By Guru in 2020 Part-3
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Fundamental Tutorial By Guru in 2020 Part-4
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Fundamental Tutorial By Guru in 2020 Part-5
![play](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/playhover.png)
Terraform Advance Tutorial for Beginners with Demo 2020 — By DevOpsSchool
![loading](https://www.devopsschool.com/blog/wp-content/plugins/youtube-embed-plus/images/gallery-page-loader.gif)
Latest posts by Rajesh Kumar (see all)
- How to remove sensitive warning from ms office powerpoint - July 14, 2024
- AIOps and DevOps: A Powerful Duo for Modern IT Operations - July 14, 2024
- Leveraging DevOps and AI Together: Benefits and Synergies - July 14, 2024