[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-682031-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-682031-en":130,"doc-similar-682031":186},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","the-terraform-book-chapter-3-building-an-application-stack-with-terraform","The Terraform Book - Chapter 3 - Building an application stack with Terraform","","Chapter 3 of The Terraform Book guides readers through building a multi-tier web application using Terraform. It starts with designing a two-tier stack on Amazon Web Services within an Amazon VPC, including an Elastic Load Balancer distributing traffic to two EC2 instances. The chapter then explains how to parameterize configuration using variables, discusses configuration structure, and introduces key constructs such as variables, maps, lists, and module-related concepts to support scalable infrastructure provisioning.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/the-terraform-book-chapter-3-building-an-application-stack-with-terraform/682031/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/the-terraform-book-chapter-3-building-an-application-stack-with-terraform/682031.png","ImageObject",300,407,{"name":42,"@type":43},"วิน","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-24","2026-11-06",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What infrastructure components does the chapter use to create the application stack?","Question",{"text":62,"@type":63},"It builds a two-tier web application stack with an Amazon Elastic Load Balancer and two EC2 instances in an AWS VPC environment.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"Why does the chapter emphasize parameterizing Terraform configuration?",{"text":67,"@type":63},"Parameterization centralizes and manages values, avoiding hard-coded repetition and improving practicality and efficiency when updates are needed across the configuration.",{"name":69,"@type":60,"acceptedAnswer":70},"How do variables help manage configuration values in Terraform?",{"text":71,"@type":63},"Variables allow readers to centralize and reuse configuration values, using a dedicated variables file (e.g., variables.tf) to hold those inputs for the configuration.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},682031,1793958626,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":79,"read_time":144,"preview_page_count":123,"preview_urls":145},2336475104736,"https://ap-avatar.wpscdn.com/avatar/22000c4c5e0e5b17e70?x-image-process=image/resize,m_fixed,w_180,h_180&k=1786591360781797222","The Terraform Book  \nJames Turnbull  \nAugust 26, 2019  \nVersion: v1.5.0 (0beb4ee)  \nWebsite: The Terraform Book  \nSome rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical or photocopying, recording, or otherwise, for commercial purposes without the prior permission of the publisher.  \nThis work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of  \nthis license, visit here.  \n© Copyright 2016-James Turnbull \u003C>  \nContents  \nPage  \nChapter 3 Building an application stack with Terraform 1  \nOur application stack .............................. 1  \nParameterizing our configuration ....................... 3  \nVariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4  \nMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9  \nLists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11  \nVariable defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13  \nPopulating variables ............................. 15  \nStarting our stack ................................. 20  \nUsing AWS shared credentials ....................... 23  \nFirst resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26  \nModules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29  \nDefining a module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  \nModule structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34  \nUsing our module ................................. 45  \nGetting our module ............................. 47  \nMoving our module to a repository ................... 48  \nCounts and counting ............................... 52  \nSets of counted resources using splat .................. 54  \nSetting values with count indexes .................... 55  \nWrapping counts with the element function .............. 59  \nConditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60  \nLocals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62  \nProvisioning our stack .............................. 64  \nFinishing up our stack .............................. 66  \nCommitting our configuration ......................... 67  \nValidating and formatting ............................ 68  \nInitializing Terraform .............................. 69  \nPlanning our stack ................................ 69  \nApplying our stack ................................ 71  \nGraphing our stack ................................ 74  \nSeeing the results ................................. 75  \nDestroying the web stack resources ...................... 77  \nSummary ...................................... 77  \nList of Figures 79  \nList of Listings 83  \nIndex 84  \nChapter 3  \nBuilding an application stack with Terraform  \nIn the last chapter we installed Terraform and got a crash course in the basics of creating, managing, and destroying infrastructure. We learned about Terraform configuration files and the basics of Terraform syntax.  \nIn this chapter we’re going to build a more complex infrastructure: a multi-tier web application. We’re going to use this exercise to learn more about Terraform configuration syntax and structure.  \nOur application stack  \nWe’re going to build a two-tier web application stack. We’re going to build this stack in Amazon Web Services (AWS) in an Amazon VPC environment. We’ll create that VPC and the supporting infrastructure as well as the stack itself. The stack will be made up of two components:  \n• An Amazon Elastic Load Balancer (ELB).  \n• Two EC2 instances.  \nThe ELB will be load balancing between our two EC2 instances.  \nFigure 3.1: Our web application stack  \nBefore we build the stack, we’re going to learn about a new concept: parameterizing your configuration.  \n􀁵 WARNING If you’re following","cbCaitksval9wTJw","https://ap.wps.com/l/cbCaitksval9wTJw","pdf",2103993,91,"English","# Building an application stack with Terraform\n## Our application stack\n## Parameterizing our configuration\n## Variables\n## Maps\n## Lists\n## Variable defaults\n## Populating variables\n## Starting our stack\n## Using AWS shared credentials\n## Modules\n## Provisioning our stack\n## Validating and formatting\n## Initializing Terraform\n## Planning our stack\n## Applying our stack\n## Graphing our stack\n## Seeing the results\n## Destroying the web stack resources\n## Summary","[{\"question\":\"What infrastructure components does the chapter use to create the application stack?\",\"answer\":\"It builds a two-tier web application stack with an Amazon Elastic Load Balancer and two EC2 instances in an AWS VPC environment.\"},{\"question\":\"Why does the chapter emphasize parameterizing Terraform configuration?\",\"answer\":\"Parameterization centralizes and manages values, avoiding hard-coded repetition and improving practicality and efficiency when updates are needed across the configuration.\"},{\"question\":\"How do variables help manage configuration values in Terraform?\",\"answer\":\"Variables allow readers to centralize and reuse configuration values, using a dedicated variables file (e.g., variables.tf) to hold those inputs for the configuration.\"}]","The Terraform Book - Chapter 3 - Building an application stack with Terraform | PDF",229,[146,150,154,158,162,166,170,174,178,182],{"page_no":22,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/4b7a99ba8ac112f557b524b0c1ef5b8e.webp",983,1272,{"page_no":26,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/e08f23f94d2e465fcd037b37e5a68140.webp",982,1270,{"page_no":30,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/e808a0fbf06f16b7fb96a3aa59b0674e.webp",981,1269,{"page_no":33,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/493ac91fc8477484ddcf496233ca475c.webp",980,1268,{"page_no":96,"url":163,"width":164,"height":165},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/a79f49cf3bc0e0ed27c03c264cb75b36.webp",979,1267,{"page_no":101,"url":167,"width":168,"height":169},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/3822b65b917918851505f5dfc7149dec.webp",978,1265,{"page_no":105,"url":171,"width":172,"height":173},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/571fdeba7fef8d2591690688e0d4c9f3.webp",977,1264,{"page_no":110,"url":175,"width":176,"height":177},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/3fbda906e0ba1f589c75db5e7493bc88.webp",976,1263,{"page_no":115,"url":179,"width":180,"height":181},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/556a9783ce275c313363fcf913cc35ae.webp",975,1261,{"page_no":123,"url":183,"width":184,"height":185},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/af3cf14b51a7d0f0a9e3b3ecf59c6a8a.webp",974,1260,{"list":187,"token":11},[188,194,201,207,213,219,226,232,238,244],{"doc_id":189,"doc_title":190,"file_type":137,"home_preview_img_url":191,"slug":192,"view_count":105,"category_name":29,"create_tm":193},682032,"Introduction to Terraform OSS on AWS - Technical Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999332318/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=gPJEctFfXCeRGX6K4%2BYE0syUFBw%3D","introduction-to-terraform-oss-on-aws-technical-guide",1793958631,{"doc_id":195,"doc_title":196,"file_type":137,"home_preview_img_url":197,"slug":198,"view_count":199,"category_name":29,"create_tm":200},154208,"Charon - Declarative Provisioning and Deployment","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229869942630/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=i9AkWS3pUYEzLYymYQXrYhJosnQ%3D","charon-declarative-provisioning-and-deployment",12,1787889561,{"doc_id":202,"doc_title":203,"file_type":137,"home_preview_img_url":204,"slug":205,"view_count":22,"category_name":29,"create_tm":206},760767,"AWS Administration - The Definitive Guide - Second Edition","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230044526720/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=kQ6B%2FxOLPOubyOWR%2B%2F71F8Tqs84%3D","aws-administration-the-definitive-guide-second-edition",1795909379,{"doc_id":208,"doc_title":209,"file_type":137,"home_preview_img_url":210,"slug":211,"view_count":110,"category_name":29,"create_tm":212},656184,"Web Application Architecture on AWS - Reference Architecture Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975302407/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=BI6CzIFpqJhhQy%2Fg8kLP8OJ17IA%3D","web-application-architecture-on-aws-reference-architecture-guide",1792966883,{"doc_id":214,"doc_title":215,"file_type":137,"home_preview_img_url":216,"slug":217,"view_count":96,"category_name":29,"create_tm":218},686325,"AWS Builder Labs List - read online free","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000726525/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=sNNysr%2BOzKAKPFYJwe30DBxaF1o%3D","aws-builder-labs-list-read-online-free",1794036982,{"doc_id":220,"doc_title":221,"file_type":137,"home_preview_img_url":222,"slug":223,"view_count":224,"category_name":29,"create_tm":225},203880,"Henry Khosasih - CV","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229882570796/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=7%2BEC%2FdU%2Bi7lmPAqyrKUvgY2RbHI%3D","henry-khosasih-cv",16,1788564608,{"doc_id":227,"doc_title":228,"file_type":137,"home_preview_img_url":229,"slug":230,"view_count":110,"category_name":29,"create_tm":231},693141,"Getting Started with AWS - Free Usage Tier","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230005090809/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=zNvAj8qy2cdHdUfPfrlzoU6Xvmc%3D","getting-started-with-aws-free-usage-tier",1794250462,{"doc_id":233,"doc_title":234,"file_type":137,"home_preview_img_url":235,"slug":236,"view_count":22,"category_name":29,"create_tm":237},760777,"Database Application Deployment on AWS with Amazon EC2 and AMD - Solution Brief","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230044527394/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=kQbTOOxggb8aOYQswegZGv6Ybis%3D","database-application-deployment-on-aws-with-amazon-ec2-and-amd-solution-brief",1795909512,{"doc_id":239,"doc_title":240,"file_type":137,"home_preview_img_url":241,"slug":242,"view_count":96,"category_name":29,"create_tm":243},682023,"Terraform for Developers - Essentials of Infrastructure Automation and Provisioning","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999331896/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=%2BB5JTT4h5YQHtxUPoGV7YUVLc2M%3D","terraform-for-developers-essentials-of-infrastructure-automation-and-provisioning",1793958605,{"doc_id":245,"doc_title":246,"file_type":137,"home_preview_img_url":247,"slug":248,"view_count":96,"category_name":29,"create_tm":243},682024,"Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998415734/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111459&Signature=8Yuiv3auSEW6cPnpCpsqxK3r%2F18%3D","hashicorp-terraform-deep-dive-with-no-fear-victor-turbinsky-texuna"]