{"id":7539,"date":"2019-10-30T06:29:53","date_gmt":"2019-10-30T06:29:53","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=7539"},"modified":"2023-04-03T07:25:56","modified_gmt":"2023-04-03T07:25:56","slug":"terraform-variable-number-type-explained","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/terraform-variable-number-type-explained\/","title":{"rendered":"Terraform Tutorials: Variables &#8211; Data Type &#8211; Number"},"content":{"rendered":"\n<p>In this example, the <code>instance_count<\/code> variable is defined with a type of <code>number<\/code>, and it is given a default value of <code>1<\/code>. The AWS provider is then configured to use the <code>us-west-2<\/code> region.<\/p>\n\n\n\n<p>The <code>aws_instance<\/code> resource is used to launch Amazon EC2 instances. The <code>count<\/code> argument is set to the value of the <code>instance_count<\/code> variable, which means that Terraform will launch <code>instance_count<\/code> number of EC2 instances.<\/p>\n\n\n\n<p>You can change the value of <code>instance_count<\/code> by modifying the default value in the variable definition, or you can specify a different value when you run Terraform by using the <code>-var<\/code> flag. For example, if you want to launch 3 instances, you can run the following command:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/6a4bfd9f9f28c65e76e85a9e4ae94d2d.js\"><\/script>\n\n\n\n<p>$ terraform apply -var &#8216;instance_count=3&#8217;<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/a796679861c274eee5e8ea5651d69b9f.js\"><\/script>\n\n\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_20506\"><iframe loading=\"lazy\"  id=\"_ytid_65804\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_20506\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>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&#8230; <\/p>\n","protected":false},"author":1,"featured_media":7790,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5129],"tags":[],"class_list":["post-7539","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-terraform"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=7539"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7539\/revisions"}],"predecessor-version":[{"id":33196,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7539\/revisions\/33196"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/7790"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=7539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=7539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=7539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}