{"id":8114,"date":"2019-12-21T10:16:27","date_gmt":"2019-12-21T10:16:27","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=8114"},"modified":"2023-04-03T07:26:52","modified_gmt":"2023-04-03T07:26:52","slug":"terraform-variable-boolean-type-explained","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/terraform-variable-boolean-type-explained\/","title":{"rendered":"Terraform Tutorials: Variables &#8211; Data Type &#8211; Boolean"},"content":{"rendered":"\n<p>The last of the available variable types is boolean. They give the option to employ simple true or false values. For example, you might wish to have a variable that decides when to generate the root user password on a new deployment.<\/p>\n\n\n\n<p>variable &#8220;set_password&#8221; {<br>\n    default = false<br>\n}<br>\nThe above example boolean can be used similarly to a string variable by simply marking down the correct variable.<\/p>\n\n\n\n<p>create_password = &#8220;${var.set_password}&#8221;<\/p>\n\n\n\n<p>By default, the value is set to false in this example. However, you can overwrite the variable at deployment by assigning a different value in a command line variable.<\/p>\n\n\n\n<p>terraform apply -var set_password=&#8221;true&#8221;<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/1e031081ac997112737e82ece1f2c843.js\"><\/script>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_83246\"><iframe loading=\"lazy\"  id=\"_ytid_15302\"  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_83246\"  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>The last of the available variable types is boolean. They give the option to employ simple true or false values. For example, you might wish to have a variable that&#8230; <\/p>\n","protected":false},"author":1,"featured_media":8185,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5129],"tags":[],"class_list":["post-8114","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\/8114","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=8114"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8114\/revisions"}],"predecessor-version":[{"id":33200,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8114\/revisions\/33200"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/8185"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=8114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=8114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=8114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}