Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1179536%22%20slang%3D%22en-US%22%3EStructuring%20Infrastructure%20as%20code%20for%20the%20Enterprise%20using%20Terraform%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1179536%22%20slang%3D%22en-US%22%3E%3CH3%20id%3D%22h_3557328351582040380594%22%20id%3D%22toc-hId-1088291191%22%20id%3D%22toc-hId-1088291191%22%3EPart%201%3A%26nbsp%3B%20%3CA%20href%3D%22%23h_29022492541582037936224%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EThe%20Project%3C%2FA%3E%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_559593697131582046293397%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDevops%20repo%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_66450299471582038896301%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EOverview%20of%20the%20Terraform%20Project%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_65640365351582039788481%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPacker%20project%20structure%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_632451361171582041246866%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ENaming%20conventions%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_248331063261582041255337%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EConfiguration%20Options%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20id%3D%22h_197140441211582046335200%22%20id%3D%22toc-hId--719163272%22%20id%3D%22toc-hId--719163272%22%3EPart%202%3A%20%3CA%20href%3D%22%23h_66450299471582038896301%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20Wrapper%20Overview%3C%2FA%3E%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_516839903301582049942641%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EOverview%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_744882883101582049925541%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECommand%20Review%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_13154615211582049935696%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EExample%20Commands%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20id%3D%22toc-hId-1768349561%22%20id%3D%22toc-hId-1768349561%22%3EPart%203%3A%20%3CA%20href%3D%22%23h_938501060181582050470724%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploying%20the%20first%20environment%3C%2FA%3E%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_846497989281582050483019%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploying%20Core%20Resources%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_388630597371582050870557%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBuilding%20first%20Packer%20Image%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_2709635791582051641540%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20Squid%20Proxy%20VMs%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_792001999181582051707596%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBuild%20second%20Packer%20image%20(proxy%20aware)%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_36857769281582051731410%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20SQL%20Server%20%2F%20Database%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_443450927371582051754149%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20NodeJS%20VM's%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_274585552461582051783801%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20Nginx%20VM's%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_480379056551582051801936%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20Core%20Resources%20for%20Secondary%20Region%20(optional)%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_480379056551582051801936%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEnabling%20Log%20Analytics%20(optional)%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22%23h_480379056551582051801936%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEnable%20Remote%20State%20(optional)%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20an%20example%20of%20how%20you%20could%20begin%20to%20structure%20your%20terraform%20project%20to%20deploy%20the%20same%20terraform%20code%20to%20multiple%20customers%2C%20environments%20or%20regions.%26nbsp%3B%20The%20project%20will%20also%20give%20you%20consist%20naming%20across%20all%20your%20resources%20in%20a%20given%20deployment.%26nbsp%3B%20We%20will%20not%20be%20able%20to%20cover%20all%20of%20the%20options%20in%20this%20project%20but%20will%20cover%20the%20basics%20to%20get%20you%20started.%26nbsp%3B%20By%20no%20means%20should%20this%20project%20be%20deployed%20without%20modification%20to%20include%20security%2C%20monitoring%20and%20other%20key%20components%20to%20harden%20your%20environment.%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E***%20Project%20is%20written%20in%20Terraform%20v12%3C%2FP%3E%0A%3CP%3E***%20Users%20should%20have%20a%20general%20understanding%20of%20Terraform%20HCL%3C%2FP%3E%0A%3CP%3E***%20This%20is%20an%20example%20%2F%20guide%20not%20a%20production%20ready%20template.%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhat%20is%20being%20built%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20example%20we%20will%20deploy%202%20squid%20proxy%20servers%20for%20outbound%20traffic%2C%202%20nginx%20servers%20in%20front%20of%20a%20public%20load%20balancer%2C%202%20nodejs%20web%20servers%20in%20front%20of%20a%20private%20load%20balancer%20and%20a%20single%20Azure%20SQL%20Database%20with%20service%20tunneling%20enabled.%26nbsp%3B%20All%20DNS%20resolution%20will%20be%20through%20Azure%20Private%20DNS%20zones%20which%20is%20configured%20when%20building%20the%20base%20image%20using%20Packer.%26nbsp%3B%20The%20nginx%20servers%20will%20act%20as%20the%20frontend%20which%20will%20route%20traffic%20to%20a%20private%20LB%20in%20front%20of%20the%20nodejs%20app%20which%20connects%20to%20the%20Azure%20SQL%20Server%20all%20of%20which%20is%20configured%20on%20deploy%20through%20cloud-init.%26nbsp%3B%20SSH%20access%20will%20be%20disabled%20remotely%20and%20is%20only%20allowed%20via%20Azure%20Bastion.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorrohrerx4_8%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22diagram.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171701i25415CE73746883F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22diagram.png%22%20alt%3D%22diagram.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH4%20id%3D%22h_29022492541582037936224%22%20id%3D%22toc-hId--1836056261%22%20id%3D%22toc-hId--1836056261%22%3E%3CSTRONG%3EThe%20Project%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CH4%20id%3D%22h_559593697131582046293397%22%20id%3D%22toc-hId-651456572%22%20id%3D%22toc-hId-651456572%22%3E%3CSTRONG%3EThe%20repo%20(clone)%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CPRE%3Egit%20clone%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac.git%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac.git%3C%2FA%3E%20%3C%2FPRE%3E%0A%3CP%20data-unlink%3D%22true%22%3E%3CBR%20%2F%3EView%20the%20project%20online%20%26gt%3B%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E*Feel%20free%20to%20contribute%20or%20give%20feedback%20directly%20on%20the%20repo.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CH4%20id%3D%22h_66450299471582038896301%22%20id%3D%22toc-hId--1155997891%22%20id%3D%22toc-hId--1155997891%22%3E%3CSTRONG%3EOverview%20of%20the%20Project%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CH5%20id%3D%22toc-hId--465436417%22%20id%3D%22toc-hId--465436417%22%3E%3CSTRONG%3EHigh%20Level%20Project%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22high%20level.png%22%20style%3D%22width%3A%20355px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171776iD8A2188F3D2B76AD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22high%20level.png%22%20alt%3D%22high%20level.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ELevel%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EAdditional%20Information%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eterraform%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eazure%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThis%20level%20is%20referred%20to%20as%20the%20cloud%20level%20which%20is%20defaulted%20as%20azure%20in%20deploy.py%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eterraform%2Fazure%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fdeployments%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edeployments%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20terraform%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fconfiguration%2Fvariables.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Evariable%20files%3C%2FA%3E%20for%20different%20isolated%20deployments.%26nbsp%3B%20These%20variable%20files%20are%20fed%20into%20the%20section%20(main)%20and%20drive%20naming%2C%20configuration%E2%80%A6%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eterraform%2Fazure%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fmain%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emain%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%22Main%22%20is%20also%20called%20a%20section%20in%20the%20deploy.py.%26nbsp%3B%20Each%20section%20gets%20its%20own%20terraform%20state%20file%20(local%20or%20remote).%26nbsp%3B%20You%20can%20have%20as%20many%20sections%20as%20possible%20and%20use%20terraform%20data%20sources%20to%20related%20resources%20between%20them.%26nbsp%3B%20Deployment%20variable%20files%20are%20shared%20across%20all%20sections.%26nbsp%3B%20An%20example%20of%20this%20could%20be%20to%20have%20a%20%22main%22%20sections%20for%20all%20things%20and%20a%20%22NSG%22%20section%20for%20only%20NSG%20rules%20(subnet%2C%20NIC%2C%20etc).%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eterraform%2Fazure%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fmodules%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emodules%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ETerraform%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fconfiguration%2Fmodules.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emodules%3C%2FA%3E%20which%20can%20reused%20and%20referenced%20across%20any%20section.%26nbsp%3B%20There%20is%20a%20marketplace%20with%20modules%20or%20you%20can%20write%20your%20own%20like%20I%20did.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eterraform%2Fazure%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fpacker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epacker%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20packer%20deployment%20and%20os%20files%20used%20to%20build%20images.%26nbsp%3B%20Deployment%20files%20are%20auto%20generated%20based%20on%20first%20run%20terraform%20run%20of%20%22main%22%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eterraform%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Fblob%2Fmaster%2Fterraform%2Fdeploy.py%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edeploy%2Cpy%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EPython3%20wrapper%20script%20which%20is%20used%20to%20control%20terraform%20%2F%20packer%20executions.%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Fblob%2Fmaster%2FREADME.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EREADME.md%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EIn%20depth%20instructions%20with%20common%20deploy.py%20terraform%20%2F%20packer%20commands%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-2022076416%22%20id%3D%22toc-hId-2022076416%22%3E%3CSTRONG%3EDeployment%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ELevel%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EAdditional%20Information%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fdeployments%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edeployments%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20terraform%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fconfiguration%2Fvariables.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Evariable%20files%3C%2FA%3E%20for%20different%20isolated%20deployments.%26nbsp%3B%20These%20variable%20files%20are%20fed%20into%20the%20section%20(main)%20and%20drive%20naming%2C%20configuration%E2%80%A6%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fdeployments%2F%3CFOLDER%3E%3C%2FFOLDER%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CFOLDER%3E%20under%20deployments%20ultimately%20act%20as%20a%20deployment%20or%20separate%20environment.%26nbsp%3B%20In%20my%20example%20US1%20has%20configured%20for%20USGov%20and%20US2%20is%20configured%20for%20a%20US%20Commercial%20deployment.%3C%2FFOLDER%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fdeployments%2F%3CFOLDER%3E%2Fdeployment.tfvars%3C%2FFOLDER%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThis%20is%20the%20variable%20file%20which%20is%20passed%20into%20the%20%22main%22%20section%20and%20drives%20the%20configuration%20for%20the%20environment.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fdeployments%2F%3CFOLDER%3E%2Fsecrets.tfvars%3C%2FFOLDER%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThis%20is%20the%20variable%20file%20which%20is%20passed%20into%20the%20%22main%22%20section%20and%20drives%20the%20configuration%20for%20the%20environment%20along%20with%20deployment.tfvars%20except%20this%20one%20is%20excluded%20in%20any%20commits%20using%20.gitignore.%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fdeployments%2F%3CFOLDER%3E%2Fstate%2Fmain%3C%2FFOLDER%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EIf%20using%20local%20state%20the%20state%20file%20will%20be%20deployed%20in%20this%20folder.%26nbsp%3B%20Deploy.py%20also%20will%20keep%20a%2030%20day%20rolling%20backup%20of%20state%20in%20this%20folder.%26nbsp%3B%20If%20your%20using%20remote%20state%20this%20folder%20will%20not%20exist.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-214621953%22%20id%3D%22toc-hId-214621953%22%3E%3CSTRONG%3EMain%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22main.png%22%20style%3D%22width%3A%20172px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171704i903F065CBC6551A8%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22main.png%22%20alt%3D%22main.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ELevel%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EAdditional%20Information%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fmain%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emain%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%22Main%22%20is%20also%20called%20a%20section%20in%20the%20deploy.py.%26nbsp%3B%20Each%20section%20gets%20its%20own%20terraform%20state%20file%20(local%20or%20remote).%26nbsp%3B%20You%20can%20have%20as%20many%20sections%20as%20possible%20and%20use%20terraform%20data%20sources%20to%20related%20resources%20between%20them.%26nbsp%3B%20Deployment%20variable%20files%20are%20shared%20across%20all%20sections.%26nbsp%3B%20An%20example%20of%20this%20could%20be%20to%20have%20a%20%22main%22%20sections%20for%20all%20things%20and%20a%20%22NSG%22%20section%20for%20only%20NSG%20rules%20(subnet%2C%20NIC%2C%20etc).%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2F.terraform%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EFolder%20which%20is%20created%20by%20terraform.%26nbsp%3B%20Contains%20providers%2C%20module%20information%20as%20well%20as%20backend%20state%20metadata.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2F%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frohrerb%2Fterraform-eiac%2Ftree%2Fmaster%2Fterraform%2Fazure%2Fmain%2Fcloud-init%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ecloud-init%2F%3C%2FA%3E%3CVM_TYPE%3E_cloudconfig.tpl%3C%2FVM_TYPE%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcloudinit.readthedocs.io%2Fen%2Flatest%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECloud-init%3C%2FA%3E%20folder%20contains%20vm%20type%20specific%20cloud-init%20tpl%20files.%20If%20no%20file%20exists%20for%20a%20vm%20type%20the%20VM%20will%20not%20have%20a%20value%20in%20%22custom_data%22.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fbackend.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ETarget%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fbackends%2Ftypes%2Fazurerm.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ebackend%3C%2FA%3E%20which%20is%20ultimately%20controlled%20by%20%60deploy.py%60%26nbsp%3B%20%3CI%3EBackend%20config%20values%20are%20added%20to%20the%20command%20line.%3C%2FI%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fdata.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20any%20high%20level%20%60data%60%20terraform%20resources.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fimages.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EHolds%20multiple%20azurerm_image%20resources%20which%20pull%20packer%20images%20from%20a%20resource%20group.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Flocals.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fconfiguration%2Flocals.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELocal%3C%2FA%3E%20values%20which%20are%20used%20in%20the%20root%20module%20(main).%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fnetwork.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20network%2C%20subnet%2C%20watcher%20and%20a%20few%20other%20network%20related%20resources.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fpacker.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ELocal%20File%20resource%20which%20is%20used%20to%20write%20the%20packer%20configuration%20files.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fprovider.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ETarget%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fproviders%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eprovider%3C%2FA%3E%20resource.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Frecovery_vault.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EAzure%20Site%20recovery%20terraform%20resources%20which%20are%20used%20to%20protect%20VMs%20in%20a%20secondary%20region.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fremote_state.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EProject%20allows%20you%20to%20have%20a%20local%20state%20or%20a%20remote%20state.%26nbsp%3B%20This%20file%20contains%20the%20resources%20required%20to%20host%20state%20in%20a%20blob%20storage%20account.%26nbsp%3B%20100%25%20driven%20by%20a%20variable.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fsql_server.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20the%20resources%20to%20deploy%20Azure%20SQL%20Databases%20and%20related%20resources.%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fresource_groups.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EContains%20multiple%20resource%20group%20terraform%20resources%20to%20hold%20the%20many%20resources%20created%20by%20this%20project.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fvariables.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EVariables%20used%20in%20the%20deployment%20in%20the%20root%20module.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fvm_lngx.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EExample%20of%20a%20VM%20type%20instance.%26nbsp%3B%20%60vm_%60%20is%20just%20a%20prefix%20to%20keep%20them%20together.%26nbsp%3B%20%60lngx%60%20first%20character%20%60l%60%20for%20linux%20and%20%60sql%60%20to%20describe%20what%20workload%20the%20vm%20is%20running.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fvm_lsqd.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EExample%20of%20a%20VM%20type%20instance.%26nbsp%3B%20%60vm_%60%20is%20just%20a%20prefix%20to%20keep%20them%20together.%26nbsp%3B%20%60lsqd%60%20first%20character%20%60l%60%20for%20linux%20and%20%60web%60%20to%20describe%20what%20workload%20the%20vm%20is%20running.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId--1592832510%22%20id%3D%22toc-hId--1592832510%22%3E%3CSTRONG%3EMain%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22main_modules.png%22%20style%3D%22width%3A%20197px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171709i891C01FCB91B718E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22main_modules.png%22%20alt%3D%22main_modules.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorrohrerx4_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ELevel%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EAdditional%20Information%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eazure%2Fmain%2Fmodules%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EThis%20folder%20contains%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fconfiguration%2Fmodules.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ecustom%20modules%3C%2FA%3E%20which%20are%20leveraged%20within%20the%20root%20module%20(main).%26nbsp%3B%26nbsp%3B%20There%20is%20a%20large%20registry%20of%20modules%20already%20built%20which%20can%20be%20pulled%20in.%20%3CA%20href%3D%22https%3A%2F%2Fregistry.terraform.io%2Fbrowse%2Fmodules%3Fprovider%3Dazurerm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fregistry.terraform.io%2Fbrowse%2Fmodules%3Fprovider%3Dazurerm%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_65640365351582039788481%22%20id%3D%22toc-hId--372465015%22%20id%3D%22toc-hId--372465015%22%3E%3CSTRONG%3EPacker%3A%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22packer.png%22%20style%3D%22width%3A%20173px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171712i1CE2A201BDDAF404%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22packer.png%22%20alt%3D%22packer.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22144.817px%22%20height%3D%2230px%22%3E%0A%3CP%3E%3CSTRONG%3ELevel%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22579.183px%22%20height%3D%2230px%22%3E%0A%3CP%3E%3CSTRONG%3EAdditional%20Information%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22144.817px%22%20height%3D%2257px%22%3E%0A%3CP%3Eazure%2Fpacker%2Fdeployments%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22579.183px%22%20height%3D%2257px%22%3E%0A%3CP%3EThis%20folder%20contains%20deployment.json%20files%20for%20each%20terraform%20deployment.%26nbsp%3B%20These%20files%20are%20100%25%20dynamically%20created%20by%20azure%2Fmain%2Fpacker.tf%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22144.817px%22%20height%3D%22228px%22%3E%0A%3CP%3Eazure%2Fpacker%2Fos%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22579.183px%22%20height%3D%22228px%22%3E%0A%3CP%3EThis%20folder%20contains%20the%20different%20os%20specific%20packer%20files%20which%20are%20used%20in%20the%20deploy.py%20script.%26nbsp%3B%26nbsp%3B%20Any%20changes%20to%20the%20provisioners%20will%20affected%20the%20base%20images%20which%20all%20VM's%20are%20created%20from.%20Specific%20VM%20type%20modifications%20should%20be%20made%20using%20cloud-init.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CH4%20id%3D%22toc-hId-2115047818%22%20id%3D%22toc-hId-2115047818%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22h_632451361171582041246866%22%20id%3D%22toc-hId-307593355%22%20id%3D%22toc-hId-307593355%22%3E%3CSTRONG%3ENaming%20Conventions%3A%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDeploying%20using%20the%20template%20will%20provide%20a%20consisting%20naming%20convention%20across%20your%20environments.%26nbsp%3B%20The%20deployment.tfvars%20file%20contains%20several%20variables%20which%20will%20drive%20your%20resource%20naming.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3Eenvironment_code%20%20%20%20%20%20%20%20%3D%20%22d%22%20%20%20%20%20%20%20%23Environment%20Code%20(d%20%3D%20dev%2C%20q%20%3D%20qa%2C%20p%20%3D%20prod%2C%20etc)%0A%0Adeployment_code%20%20%20%20%20%20%20%20%20%3D%20%22us2%22%20%20%20%20%23Deployment%20Code%20(CountryCode%20plus%20a%20number%20usually%20a%20iterator)%0A%0Alocation_code%20%20%20%20%20%20%20%20%20%20%20%3D%20%22ea1%22%20%20%20%20%20%20%20%20%20%23Location%20Code%20(Location%20of%20the%20region%20%2F%20DC%20plus%20number%20usually%20a%20iterator)%0A%0Alocation_code_secondary%20%3D%20%22we1%22%20%20%20%20%20%20%20%20%20%23Location%20Code%20for%20Secondary%20Region%20(Location%20of%20the%20region%20%2F%20DC%20plus%20number%20usually%20a%20iterator)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMost%20resources%20are%20prefixed%20using%20full%20environment%20code%20(above)%20which%20is%20made%20up%20of%3C%2FP%3E%0A%3CPRE%3Eenvironment_code%20%2B%20deployment_code%20%2B%20location_code%3C%2FPRE%3E%0A%3CP%3EExample%20of%20resource%20groups%20names%20using%20the%20above%20values.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorrohrerx4_6%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22rg_deployment.png%22%20style%3D%22width%3A%20363px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171716iF68DB052A0DDE80E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22rg_deployment.png%22%20alt%3D%22rg_deployment.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_248331063261582041255337%22%20id%3D%22toc-hId--1499861108%22%20id%3D%22toc-hId--1499861108%22%3E%3CSTRONG%3EConfiguration%20Options%3A%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20are%20some%20of%20the%20variable%20options%20available%20per%20deployment.tfvars%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%2230px%22%3E%0A%3CP%3E%3CSTRONG%3EVariable%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%2230px%22%3E%0A%3CP%3E%3CSTRONG%3EExample%20Value%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%2230px%22%3E%0A%3CP%3E%3CSTRONG%3ERequired%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%2230px%22%3E%0A%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22139px%22%3E%0A%3CP%3Esubscription_id%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22139px%22%3E%0A%3CP%3E%227d559a72-c8b6-4d07-9ec0-5ca5b14a25e7%22%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22139px%22%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22139px%22%3E%0A%3CP%3ESubscription%20which%20all%20resources%20will%20be%20deployed%20into.%26nbsp%3B%20User%20deploying%20must%20have%20access%20to%20this%20subscription.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22194px%22%3E%0A%3CP%3Eenable_remote_state%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22194px%22%3E%0A%3CP%3Efalse%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22194px%22%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22194px%22%3E%0A%3CP%3EIf%20enabled%20a%20new%20Resource%20Group%2C%20Storage%20account%2C%20Container%20will%20be%20created%20to%20hold%20the%20terraform%20state%20remotely.%20Additional%20steps%20will%20be%20required%20and%20are%20listed%20in%20a%20later%20blog%20post.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22304px%22%3E%0A%3CP%3Eenable_secondary%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22304px%22%3E%0A%3CP%3Etrue%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22304px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22304px%22%3E%0A%3CP%3EIf%20enabled%20a%20few%20other%20variables%20would%20be%20required%2C%20such%20as%20location_secondary%2C%20location_code_secondary%20.%26nbsp%3B%20It%20will%20build%20out%20this%20skeleton%20deployment%20in%20a%20secondary%20region%20for%20DR%20purposes%20which%20includes%20additional%20resource%20groups%2C%20vnet%2C%20etc.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%2257px%22%3E%0A%3CP%3Elocation%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%2257px%22%3E%0A%3CP%3E%22East%20US%22%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%2257px%22%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%2257px%22%3E%0A%3CP%3ERegion%20where%20all%20resources%20are%20deployed.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22139px%22%3E%0A%3CP%3Elocation_secondary%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22139px%22%3E%0A%3CP%3E%22West%20US%22%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22139px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22139px%22%3E%0A%3CP%3ERequired%20if%20enable_secondary%20is%20enabled.%26nbsp%3B%20This%20drives%20the%20region%20where%20the%20secondary%20resources%20are%20placed.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22277px%22%3E%0A%3CP%3Enetwork_octets%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22277px%22%3E%0A%3CP%3E%2210.3%22%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22277px%22%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22277px%22%3E%0A%3CP%3EFirst%20two%20network%20octets%20for%20the%20VNET.%26nbsp%3B%20Be%20default%20the%20VNET%20is%20configured%20with%20a%20%2F16%20space.%26nbsp%3B%20By%20default%20you%20get%20DMZ%2C%20Services%2C%20Data%2C%20Management%20and%20AzureBastion%20Subnets.%26nbsp%3B%20These%20can%20be%20changed%20under%20the%20subnet%20variable%20in%20the%20variables.tf%20file.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22194px%22%3E%0A%3CP%3Enetwork_octets_secondary%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22194px%22%3E%0A%3CP%3E%2210.4%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22194px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22194px%22%3E%0A%3CP%3ERequired%20if%20enable_secondary%20is%20enabled.%20First%20two%20network%20octets%20for%20the%20secondary%20VNET.%26nbsp%3B%20Be%20default%20the%20VNET%20is%20configured%20with%20a%20%2F16%20space.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22194px%22%3E%0A%3CP%3Eenable_recovery_services%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22194px%22%3E%0A%3CP%3Etrue%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22194px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22194px%22%3E%0A%3CP%3EIn%20enabled%20the%20resources%20are%20deployed%20to%20enable%20Azure%20Site%20Recovery%20to%20the%20secondary%20region.%26nbsp%3B%20The%20secondary%20region%20needs%20to%20be%20configured%20to%20enable%20this.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%2285px%22%3E%0A%3CP%3Eenable_bastion%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%2285px%22%3E%0A%3CP%3Etrue%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%2285px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%2285px%22%3E%0A%3CP%3EIf%20enabled%20the%20key%20components%20for%20Bastion%20Host%20will%20be%20added.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22167px%22%3E%0A%3CP%3Edeploy_using_zones%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22167px%22%3E%0A%3CP%3ETrue%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22167px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22167px%22%3E%0A%3CP%3EIf%20enabled%20and%20the%20region%20supports%20Zones%20the%20VM%2C%20LB%2C%20Public%20IP's%20will%20be%20deployed%20across%203%20zones.%26nbsp%3B%20If%20disabled%20the%20VM's%20will%20be%20deployed%20within%20a%20AVSET.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22112px%22%3E%0A%3CP%3Edns_servers%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22112px%22%3E%0A%3CP%3E%5B10.3.1.6%2C%2010.3.1.7%5D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22112px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22112px%22%3E%0A%3CP%3EPrivate%20Zones%20are%20created%20by%20default%20but%20you%20can%20override%20by%20specifying%20your%20own%20DNS%20servers.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22139px%22%3E%0A%3CP%3Evm_instance_map%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22139px%22%3E%0A%3CP%3E%7B%7D%20%23See%20below%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22139px%22%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22139px%22%3E%0A%3CP%3EA%20map%20which%20is%20used%20to%20deploy%20certain%20VM%20types%20in%20this%20deployment.%26nbsp%3B%20See%20VM%20Configuration%20Options%20below.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22195.95px%22%20height%3D%22139px%22%3E%0A%3CP%3Esql_config_map%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22241.617px%22%20height%3D%22139px%22%3E%0A%3CP%3E%7B%7D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%2278.4833px%22%20height%3D%22139px%22%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22207.95px%22%20height%3D%22139px%22%3E%0A%3CP%3EA%20map%20which%20is%20used%20to%20deploy%201%3AN%20Azure%20SQL%20Servers.%26nbsp%3B%20See%20SQL%20Server%20Configuration%20Options%20below.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-1116734444%22%20id%3D%22toc-hId-1116734444%22%3E%3CSTRONG%3EVM%20Configuration%20Options%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CI%3EOf%20course%20this%20project%20can%20be%20expanded%20to%20include%20Azure%20resource%20such%20as%20Web%20Apps%2C%20Functions%2C%20Logic%20Apps%2C%20etc%20but%20out%20of%20the%20box%20it%20includes%20VM's.%26nbsp%3B%20VM's%20are%20controlled%20by%20a%20single%20map%20in%20the%20environment.tfvars.%3C%2FI%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAll%20VM's%20are%20by%20default%20configured%20to%20use%20bastion%20host%20to%20ssh%20or%20RDP.%26nbsp%3B%20If%20you%20wish%20to%20override%20you%20will%20need%20to%20add%20a%20public%20ip%20to%20the%20VM's%20and%20open%20the%20NSG.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Evm_instance_maps%20%3D%20%7B%0A%20%20lngx%20%3D%20%7B%20count%20%3D%202%2C%20size%20%3D%20%22Standard_D2s_v3%22%2C%20os_disk_size%20%3D%2030%2C%20data_disk_count%20%3D%201%2C%20data_disk_size%20%3D%205%2C%20enable_recovery%20%3D%20false%2C%20enable_public_ip%20%3D%20false%2C%20enable_vm_diagnostics%20%3D%20false%20%7D%0A%20%20lnjs%20%3D%20%7B%20count%20%3D%200%2C%20size%20%3D%20%22Standard_D2s_v3%22%2C%20os_disk_size%20%3D%2030%2C%20data_disk_count%20%3D%202%2C%20data_disk_size%20%3D%205%20%7D%0A%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20above%20vm%20instance%20map%20would%20deploy%20these%20resources%20in%20the%20dmz%20subnet%20and%20rg%20with%20the%20following%20naming%20convention%20which%20are%20derived%20from%3C%2FP%3E%0A%3CPRE%3E%60environment_code%60%20%2B%20%60deployment_code%60%20%2B%20%60location_code%60%20%2B%20%60vm_code%60%20%2B%20%60iterator%60%3C%2FPRE%3E%0A%3CP%3EBreaddown%20of%20the%20%60%3CFONT%20color%3D%22%23808080%22%3E%3CEM%3Evm_instance_map%3C%2FEM%3E%3C%2FFONT%3E%60%20options%20for%20each%20entry%20(vm%20type)%3A%3C%2FP%3E%0A%3CPRE%3Elngx%20%3D%20%7B%20count%20%3D%202%2C%20size%20%3D%20%22Standard_D2s_v3%22%2C%20os_disk_size%20%3D%2030%2C%20data_disk_count%20%3D%201%2C%20data_disk_size%20%3D%205%2C%20enable_recovery%20%3D%20false%2C%20enable_public_ip%20%3D%20false%2C%20enable_vm_diagnostics%20%3D%20false%20%7D%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EAttritbute%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EExample%20Value%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ERequired%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3EMap%20Key%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Elngx%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMap%20Key%20which%20maps%20to%20the%20%60location_code%60%20%2B%20%60instance_type%60%20of%20the%20VM%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Ecount%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E2%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENumber%20of%20VM's%20you%20want%20to%20create%20of%20this%20type.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Esize%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EStandard_D2s_v3%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ESize%20that%20you%20want%20each%20of%20the%20VMs%20of%20this%20type%20to%20have.%26nbsp%3B%20You%20can%20use%20to%20lookup%20available%20sizes%20%3CA%20href%3D%22http%3A%2F%2Fwww.azureinstances.info%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.azureinstances.info%2F%3C%2FA%3E%20as%20well%20as%20Azure%20CLI%2C%20etc.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eos_disk_size%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E30%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ESize%20in%20GB%20of%20the%20OS%20Disk%20of%20this%20VM%20type.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Edata_disk_count%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E1%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENumber%20of%20Data%20Disks%20to%20create%20and%20attach%20to%20the%20VM%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Edata_disk_size%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E50%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ESize%20in%20GB%20of%20the%20Data%20Disks%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eenable_public_ip%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Etrue%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EIf%20enabled%20a%20public%20ip%20will%20be%20created%20and%20attached%20to%20each%20of%20the%20VM's%20nic's%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eenable_vm_diagnostics%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Efalse%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EIf%20enabled%20a%20storage%20account%20will%20be%20created%20and%20configured%20for%20this%20VM%20type%20as%20well%20as%20enabling%20diagnostics%20for%20the%20VM.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eenable_recovery%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EFalse%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EIf%20enabled%20the%20VM%20and%20all%20disks%20will%20be%20protected%20by%20Recovery%20Services.%26nbsp%3B%20%60enable_secondary%60%20and%20%60enable_recovery_services%60%20must%20be%20enabled%20in%20the%20deployment%20as%20well.%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESQL%20Server%20Configuration%20Options%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEach%20high%20level%20map%20will%20get%20you%20a%20single%20SQL%20Server%20instance%20with%201%3AN%20SQL%20Databases.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Emyapp%20%3D%20%7B%0A%20%20%20%20deploy%20%3D%20true%0A%20%20%20%20server_name%20%3D%20%22main%22%0A%20%20%20%20admin_user%20%3D%20%22sadmin%22%0A%20%20%20%20subnet_vnet_access%20%3D%20%7B%0A%20%20%20%20%20%20app%20%3D%20%20%7B%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20firewall_rules%20%3D%20%7B%0A%20%20%20%20%20%20all%20%3D%20%20%7B%20start_ip_address%20%3D%20%220.0.0.0%22%2C%20end_ip_address%20%3D%20%22255.255.255.255%22%20%7D%20%2F%2FThis%20is%20here%20as%20a%20example%2C%20please%20don't%20do%20this.%0A%20%20%20%20%7D%0A%20%20%20%20databases%20%3D%20%7B%0A%20%20%20%20%20%20main%20%3D%20%7B%20edition%20%3D%20%22Standard%22%2C%20size%20%3D%20%22S0%22%20%7D%0A%20%20%20%20%20%20qa%20%3D%20%7B%20edition%20%3D%20%22Standard%22%2C%20size%20%3D%20%22S2%22%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EAttritbute%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EExample%20Value%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ERequired%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Emap%20Key%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Emapp%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMap%20Key%20which%20is%20used%20to%20derive%20the%20name%20of%20the%20sql%20resources%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Edeploy%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Etrue%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ESwitch%20used%20to%20control%20the%20creation%20of%20the%20resources.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Eadmin_user%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Esadmin%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EUsername%20for%20the%20SQL%20Admin%20user.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Esubnet_vnet_access%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Eapp%20%3D%26nbsp%3B%20%7B%20%7D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMap%20list%20which%20will%20allow%20traffic%20from%20a%20subnet%20to%20flow%20to%20the%20SQL%20privately.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Efirewall_rules%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%26nbsp%3Ball%20%3D%26nbsp%3B%20%7B%20start_ip_address%20%3D%20%220.0.0.0%22%2C%20end_ip_address%20%3D%20%22255.255.255.255%22%20%7D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMap%20list%20of%20firewall%20rules%20to%20add%20to%20the%20sql%20server.%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3Edatabases%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%26nbsp%3Bmain%20%3D%20%7B%20edition%20%3D%20%22Standard%22%2C%20size%20%3D%20%22S0%22%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20qa%20%3D%20%7B%20edition%20%3D%20%22Standard%22%2C%20size%20%3D%20%22S2%22%20%7D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMap%20list%20of%20the%20databases%20to%20create%20under%20this%20sql%20server%20resources.%26nbsp%3B%26nbsp%3B%20Map%20key%20is%20the%20name%20of%20the%20database%2C%20edition%20and%20size%20are%20required.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CH4%20id%3D%22toc-hId--819802738%22%20id%3D%22toc-hId--819802738%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH3%20id%3D%22h_516839903301582049942641%22%20id%3D%22toc-hId-1538627376%22%20id%3D%22toc-hId-1538627376%22%3EDeploy%20Wrapper%20Overview%3C%2FH3%3E%0A%3CP%3EIf%20using%20this%20project%20you%20should%20always%20use%20the%20deploy.py%20to%20manipulate%20the%20terraform%20environment.%26nbsp%3B%20It%20handles%20wiring%20up%20all%20paths%20to%20variables%2C%20state%20as%20well%20as%20the%20backend%20configurations%20for%20local%20and%20remote%20state.%26nbsp%3B%26nbsp%3B%20In%20addition%20the%20wrapper%20handles%20switching%20cloud%20and%20changing%20accounts%20automatically%20based%20on%20terraform%20variables%20in%20the%20deployment.tfvars.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20using%20windows%2C%20please%20go%20through%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-developer-community-blog%2Fconfiguring-terraform-on-windows-10-linux-sub-system%2Fba-p%2F393845%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ethese%20steps%3C%2FA%3E%20to%20install%20Terraform%20on%20the%20Window%2010%20Linux%20Sub%20System.%26nbsp%3B%20You%20also%20need%20to%20install%20Packer%2C%20please%20install%20the%20same%20way%20you%20installed%20Terraform.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENext%20we%20need%20to%20install%20python3%20and%20pip3%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Esudo%20apt-get%20update%0Asudo%20apt-get%20install%20python3%0Asudo%20apt-get%20install%20python3-pip%0Apip3%20install%20colorama%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20wrapper%20has%20a%20detailed%20README.md%20that%20can%20help%20you%20with%20command%20help%20as%20well%20as%20example%20commands%20for%20terraform%20and%20packer.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Edeploy.py%20--help%0Ausage%3A%20deploy.py%20%5B-h%5D%20-d%20DEPLOUMENT%20%5B-c%20CLOUD%5D%20%5B-s%20SECTION%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B-a%20%5BACTION%20%5BACTION%20...%5D%5D%5D%20%5B-t%20TARGET%5D%20%5B-r%20RESOURCE%5D%20%5B-v%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B-pu%5D%20%5B-us%20UNLOCK_STATE%5D%20%5B-ss%20STATE_SNAPSHOT%5D%20%5B-p%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B-po%20PACKER_OS%5D%0A%0ARun%20Terraform%20Wrapper%0A%0Aoptional%20arguments%3A%0A%20%20-h%2C%20--help%20%20%20%20%20%20%20%20%20%20%20%20show%20this%20help%20message%20and%20exit%0A%0Arequired%20deployment%20commands%3A%0A%0A%20%20-d%20DEPLOUMENT%2C%20--deploument%20DEPLOUMENT%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Target%20Deployment%20to%20Terraform%20against%0A%0Aoptional%20enviornment%20commands%3A%0A%0A%20%20-c%20CLOUD%2C%20--cloud%20CLOUD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Cloud%20to%20Target%0A%0A%20%20-s%20SECTION%2C%20--section%20SECTION%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Section%20to%20target%20(usefull%20for%20large%20projects%20when%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20state%20is%20broken%20into%20multiple%20files.)%0A%0A%20%20-a%20%5BACTION%20%5BACTION%20...%5D%5D%2C%20--action%20%5BACTION%20%5BACTION%20...%5D%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Available%20terraform%20actions%3B%20plan%2C%20apply%2C%20taint%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20untaint%2C%20state%2C%20import%0A%0A%20%20-t%20TARGET%2C%20--target%20TARGET%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Specify%20specific%20modules%20for%20the%20selected%20--action%0A%0A%20%20-r%20RESOURCE%2C%20--resource%20RESOURCE%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ResourceID%20which%20is%20used%20if%20doing%20a%20state%20import.%0A%0A%20%20-v%2C%20--verbose%20%20%20%20%20%20%20%20%20Show%20verbose%20outputs%0A%0Aoptional%20terraform%20commands%3A%0A%20%20-pu%2C%20--plugin_update%20%20Specify%20this%20parameter%20if%20you%20wish%20to%20upgrade%2Fvalidate%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20terraform%20plugins%0A%0A%20%20-us%20UNLOCK_STATE%2C%20--unlock_state%20UNLOCK_STATE%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Use%20this%20command%20to%20unlock%20state%2C%20--unlock_state%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CLOCK_ID%3E%0A%0A%20%20-ss%20STATE_SNAPSHOT%2C%20--state_snapshot%20STATE_SNAPSHOT%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Default%20enabled%20will%20take%20a%20snapshot%20of%20the%20state%20on%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20any%20action%20except%20plan.%0A%0Aoptional%20packer%20commands%3A%0A%0A%20%20-p%2C%20--packer%20%20%20%20%20%20%20%20%20%20Specify%20this%20parameter%20along%20with%20-d%20to%20run%20a%20packer%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20build%20in%20a%20deployment%0A%20%20-po%20PACKER_OS%2C%20--packer_os%20PACKER_OS%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Specify%20this%20parameter%20if%20-p%20is%20used.%20Available%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20options%20are%20under%20%2Fpacker%2Fos%2F%3CFILENAME%3E%0A%0A%3C%2FFILENAME%3E%3C%2FLOCK_ID%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22h_744882883101582049925541%22%20id%3D%22toc-hId--10661649%22%20id%3D%22toc-hId--10661649%22%3E%3CSTRONG%3EReviewing%20the%20Commands%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EArgument%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EExample%20Value%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ERequired%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-d%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Eus1%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMatches%20the%20deployment%20folders%20in%20the%20terraform%20project%20structure.%20%60azure%2Fdeployments%2F%3CDEPLOYMENT_CODE%3E%60%3C%2FDEPLOYMENT_CODE%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-s%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Emain%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Eno%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%22main%22%20(default)%20is%20also%20called%20a%20section%20in%20the%20terraform%20project%20structure.%20%60azure%2Fmain%60%26nbsp%3B%20Each%20section%20gets%20its%20own%20terraform%20state%20file%20(local%20or%20remote).%26nbsp%3B%20You%20can%20have%20as%20many%20sections%20as%20possible%20and%20use%20terraform%20data%20sources%20to%20related%20resources%20between%20them.%26nbsp%3B%20Deployment%20variable%20files%20are%20shared%20across%20all%20sections.%26nbsp%3B%20An%20example%20of%20this%20could%20be%20to%20have%20a%20%22main%22%20sections%20for%20all%20things%20and%20a%20%22NSG%22%20section%20for%20only%20NSG%20rules%20(subnet%2C%20NIC%2C%20etc).%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-a%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Eplan%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EMaps%20to%20terraform%20commands%20(plan%2C%20apply%2C%20state%2C%20etc)%20%26gt%3B%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fcommands%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.terraform.io%2Fdocs%2Fcommands%2Findex.html%3C%2FA%3E.%26nbsp%3B%26nbsp%3B%20Plan%20is%20the%20default.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-t%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Emodule.rg-test.azurerm_resource_group.rg%5B0%5D%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ERequired%20when%20certain%20actions%20are%20used.%26nbsp%3B%20Use%20target%20when%20you%20want%20to%20perform%20a%20action%20on%20only%20a%20few%20isolated%20resources.%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fcommands%2Fplan.html%23resource-targeting%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.terraform.io%2Fdocs%2Fcommands%2Fplan.html%23resource-targeting%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-r%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%2Fsubscriptions%2F7d559a72-c8b6-4d07-9ec0-5ca5b14a25e7%2FresourceGroups%2Fdus2ea1-dmz%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ERequired%20when%20importing%20resources%20into%20state.%26nbsp%3B%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fdocs%2Fimport%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.terraform.io%2Fdocs%2Fimport%2Findex.html%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-pu%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EWhen%20used%20the%20following%20is%20added%20to%20%60terraform%20init%60%26nbsp%3B%20%60-get%3Dtrue%20-get-plugins%3Dtrue%20-upgrade%3Dtrue'.%26nbsp%3B%20Used%20when%20you%20want%20to%20upgrade%20the%20providers%2C%20however%20its%20best%20practice%20to%20pin%20providers%20in%20the%20provider.tf.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-us%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E--unlock_state%20047c2e42-69b7-4006-68a5-573ad93a769a%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EIf%20you%20are%20using%20remote%20state%20you%20may%20occasionally%20end%20up%20with%20a%20lock%20on%20the%20state%20blob.%26nbsp%3B%20To%20release%20the%20lock%20you%20can%20use%20this%20parameter%20or%20you%20can%20release%20from%20the%20azure%20portal.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E--ss%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EDefault%20is%20True%2C%20Set%20to%20False%20if%20you%20wish%20to%20NOT%20take%20a%20snapshot.%26nbsp%3B%20I%20do%20not%20recommend%20that%20you%20disable.%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-p%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ENo%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EUse%20-p%20to%20enable%20a%20Packer%20run%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E-po%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3Eubuntu%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3EYes%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3ERequired%20when%20-p%20is%20added.%26nbsp%3B%20Maps%20to%20a%20os%20file%20under%20%60azure%2Fpacker%2Fos%2F%3CFILENAME%3E%3C%2FFILENAME%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22h_13154615211582049935696%22%20id%3D%22toc-hId--1818116112%22%20id%3D%22toc-hId--1818116112%22%3E%3CSTRONG%3EExample%20Commands%3A%3C%2FSTRONG%3E%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3Bplan%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eapply%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20apply%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eapply%20w%2Ftarget%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20apply%20-t%20module.rg-test.azurerm_resource_group.rg%5B0%5D%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eapply%20w%2Ftarget(s)%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20apply%20-t%20module.rg-test.azurerm_resource_group.rg%5B0%5D%20-t%20module.rg-test.azurerm_resource_group.rg%5B%22test%22%5D%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eapply%20w%2Ftarget%20against%20a%20tf%20file.%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%26nbsp%3B%20-t%20resource_groups.tf%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Estate%20remove%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20state%20rm%20-t%20module.rg-test.azurerm_resource_group.rg%5B0%5D%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Estate%20mv%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20state%20mv%20-t%20module.rg-test.azurerm_resource_group.rg%5B0%5D%20-t%20module.rg-test2.azurerm_resource_group.rg%5B0%5D%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eimport%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20import%20-t%20module.rg-test.azurerm_resource_group.rg%5B0%5D%20-r%20%2Fsubscriptions%2F75406810-f3e6-42fa-97c6-e9027e0a0a45%2FresourceGroups%2FDUS1VA1-test%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Etaint%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20taint%20-t%20null_resource.image%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Euntaint%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20-a%20untaint%20-t%20null_resource.image%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eunlock%20a%20remote%20state%20file%3C%2FP%3E%0A%3CP%3E%3CI%3EIf%20you%20receive%20this%20message%20you%20can%20unlock%20using%20the%20below%20command.%20Grab%20the%20*ID*%20under%20*Lock%20Info%3A*%3C%2FI%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3EError%3A%20Error%20locking%20state%3A%20Error%20acquiring%20the%20state%20lock%3A%20storage%3A%20service%20returned%20error%3A%20StatusCode%3D409%2C%20ErrorCode%3DLeaseAlreadyPresent%2C%20ErrorMessage%3DThere%20is%20already%20a%20lease%20present.%0ARequestId%3A9c61c2f1-c01e-00d7-7ec1-c570f5000000%0ATime%3A2020-01-08T01%3A18%3A23.2626686Z%2C%20RequestInitiated%3DWed%2C%2008%20Jan%202020%2001%3A18%3A23%20GMT%2C%20RequestId%3D9c61c2f1-c01e-00d7-7ec1-c570f5000000%2C%20API%20Version%3D2018-03-28%2C%20QueryParameterName%3D%2C%20QueryParameterValue%3D%0A%0ALock%20Info%3A%0A%20%20ID%3A%20%20%20%20%20%20%20%20047c2e42-69b7-4006-68a5-573ad93a769a%0A%20%20Path%3A%20%20%20%20%20%20main%2Fterraform.tfstate%0A%20%20Operation%3A%20OperationTypeApply%0A%20%20Who%3A%20%20%20%20%20%20%20user%40machine_xyz%0A%20%20Version%3A%20%20%200.12.18%0A%20%20Created%3A%20%20%202020-01-08%2001%3A13%3A13.1965322%20%2B0000%20UTC%0A%20%20Info%3A%20%20%20%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-d%20us1%20--unlock_state%20047c2e42-69b7-4006-68a5-573ad93a769a%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECommon%20Packer%20Commands%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3Bbuild%20ubuntu%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-p%20-po%20ubuntu%20-d%20us1%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ebuild%20centos%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-p%20-po%20centos%20-d%20us1%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3Bbuild%20windows%3C%2FP%3E%0A%3CPRE%3Edeploy.py%20-p%20-po%20windows%20-d%20us1%3C%2FPRE%3E%0A%3CH3%20id%3D%22h_938501060181582050470724%22%20id%3D%22toc-hId-411231283%22%20id%3D%22toc-hId-411231283%22%3EDeploying%20the%20first%20environment%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_846497989281582050483019%22%20id%3D%22toc-hId--568978520%22%20id%3D%22toc-hId--568978520%22%3EDeploying%20Core%20Resources%3A%3C%2FH4%3E%0A%3COL%3E%0A%3CLI%3EOpen%20the%20vscode%20then%20File%20%26gt%3B%20Open%20Folder%20%26gt%3B%20Choose%20the%20root%20folder%20which%20was%20cloned.%3C%2FLI%3E%0A%3CLI%3EThe%20project%20is%20default%20setup%20with%20two%20deployments%3A%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%60%3CSTRONG%3Eus1%3C%2FSTRONG%3E%60%20which%20is%20setup%20for%20US%20Government%3C%2FLI%3E%0A%3CLI%3E%60%3CSTRONG%3Eus2%3C%2FSTRONG%3E%60%20which%20is%20setup%20for%20US%20Commercial%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CLI%3EWe%20will%20continue%20with%20us2%20as%20our%20deployment.%26nbsp%3B%20Open%20the%20%60%3CSTRONG%3Edeployment.tfvars%3C%2FSTRONG%3E%60%20under%20%60%3CSTRONG%3Eus2%3C%2FSTRONG%3E%60%20folder%2C%20plug%20your%20subscription%20guid%20in%20the%20empty%20quotes.%20(Save)%3C%2FLI%3E%0A%3CLI%3EClick%20Terminal%20%26gt%3B%20New%20Terminal.%26nbsp%3B%20(If%20on%20windows%2C%20type%20bash%20and%20hit%20enter%20in%20the%20terminal%20to%20enter%20WSL).%3C%2FLI%3E%0A%3CLI%3EType%20%60%3CSTRONG%3Ecd%20terraform%3C%2FSTRONG%3E%60%20so%20that%20deploy.py%20is%20in%20your%20current%20directory.%3C%2FLI%3E%0A%3CLI%3EType%20%60%3CFONT%20color%3D%22%23000000%22%3E%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-pu%20-t%20resource_groups.tf%20-a%20apply%3C%2FSTRONG%3E%3C%2FFONT%3E%60%20to%20run%20a%20apply%20targeting%20all%20of%20the%20resource%20groups.%26nbsp%3B%20When%20prompted%20type%20%60%3CSTRONG%3Eyes%3C%2FSTRONG%3E%60%20and%20then%20enter.%26nbsp%3B%20Take%20note%20of%20the%20commands%20which%20show%20in%20yellow%20(after%20Running%3A)%2C%20they%20are%20the%20actual%20commands%20which%20are%20run%20to%20bootstrap%20the%20environment%20(az%2C%20tf%20init%2Fcommand)%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ERuntime%20Variables%3A%0A%20%20%20%20%20%20%20%20%20Cloud%3A%20azure%0A%20%20%20%20%20%20%20%20%20Section%3A%20main%0A%20%20%20%20%20%20%20%20%20Deployment%3A%20us2%0A%20%20%20%20%20%20%20%20%20Action%3A%20apply%0A%20%20%20%20%20%20%20%20%20Variables%3A%20%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%2Fdeployment.tfvars%0A%20%20%20%20%20%20%20%20%20Secrets%3A%20%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%2Fsecrets.tfvars%0A%20%20%20%20%20%20%20%20%20Section%3A%20%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fmain%0A%20%20%20%20%20%20%20%20%20Deployment%3A%20%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%0A%20%20%20%20%20%20%20%20%20Target(s)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-dmz%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-services%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-management%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-data%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-network%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-network-secondary%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-packer%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20module.rg-recovery-vault%0A%0ARunning%3A%20az%20cloud%20set%20--name%20AzureCloud%0ARunning%3A%20az%20account%20set%20-s%207d559a72-xxxx-xxxx-xxxx-5ca5b14a25e7%0AStart%20local%20state%20engine...%0ARunning%3A%20terraform%20init%20-reconfigure%20-get%3Dtrue%20-get-plugins%3Dtrue%20-upgrade%3Dtrue%20-verify-plugins%3Dtrue%0A...%0ATerraform%20has%20been%20successfully%20initialized!%0A%E2%80%A6%0ATaking%20state%20snapshot%0ARunning%3A%20terraform%20apply%20-target%3Dmodule.rg-dmz%20-target%3Dmodule.rg-services%20-target%3Dmodule.rg-management%20-target%3Dmodule.rg-data%20-target%3Dmodule.rg-network%20-target%3Dmodule.rg-network-secondary%20-target%3Dmodule.rg-packer%20-target%3Dmodule.rg-recovery-vault%20-state%3D%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%2Fstate%2Fmain%2Fterraform.tfstate%20-var-file%3D%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%2Fdeployment.tfvars%20-var-file%3D%2Fmnt%2Fc%2FProjects%2Fthebarn%2Feiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%2Fsecrets.tfvars%0A...%0A%20%0ATerraform%20will%20perform%20the%20following%20actions%3A%0A%20%20%23%20module.rg-data.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22eastus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2ea1-data%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0A%20%20%23%20module.rg-dmz.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22eastus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2ea1-dmz%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0A%20%20%23%20module.rg-management.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22eastus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2ea1-management%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0A%20%20%23%20module.rg-network.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22eastus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2ea1-network%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0A%20%20%23%20module.rg-packer.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22eastus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2ea1-packer%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0A%20%20%23%20module.rg-recovery-vault.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22westus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2we1-recovery-vault%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0A%20%20%23%20module.rg-services.azurerm_resource_group.rg%5B0%5D%20will%20be%20created%0A%20%20%2B%20resource%20%22azurerm_resource_group%22%20%22rg%22%20%7B%0A%20%20%20%20%20%20%2B%20id%20%20%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%20%20%2B%20location%20%3D%20%22eastus%22%0A%20%20%20%20%20%20%2B%20name%20%20%20%20%20%3D%20%22dus2ea1-services%22%0A%20%20%20%20%20%20%2B%20tags%20%20%20%20%20%3D%20(known%20after%20apply)%0A%20%20%20%20%7D%0A%0APlan%3A%207%20to%20add%2C%200%20to%20change%2C%200%20to%20destroy.%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3CLI%3EType%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%20to%20apply%20the%20rest%20of%20the%20initial%20resources%20(network%2C%20Bastion%2C%20Watcher%2C%20etc)%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20...%0APlan%3A%2022%20to%20add%2C%200%20to%20change%2C%200%20to%20destroy.%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH4%20id%3D%22toc-hId-1918534313%22%20id%3D%22toc-hId-1918534313%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22h_388630597371582050870557%22%20id%3D%22toc-hId-111079850%22%20id%3D%22toc-hId-111079850%22%3EBuilding%20First%20Packer%20Image%3A%3C%2FH4%3E%0A%3CP%3ENext%20we%20need%20to%20build%20our%20first%20image%2C%20we%20will%20focus%20on%20only%20Ubuntu.%26nbsp%3B%20This%20first%20image%20will%20be%20solely%20used%20to%20build%20out%20the%20%60lsqd%60%20VM's%20which%20will%20be%20our%20proxy%20(squid)%20VM's.%20During%20our%202nd%20apply%20the%20packer%20configuration%20for%20us2%20was%20written%20to%20the%20packer%20deployment%20folder.%3C%2FP%3E%0A%3CP%3E%3CEM%3E*The%20first%20time%20you%20deploy%20packer%20it%20will%20require%20you%20to%20authenticate%20twice.%26nbsp%3B%26nbsp%3B%20Once%20the%20image%20is%20built%20it%20will%20land%20in%20the%20%60dus2ea1-packer%60%20resource%20group.%3C%2FEM%3E%3C%2FP%3E%0A%3CPRE%3E.%2Fdeploy.py%20-p%20-po%20ubuntu%20-d%20us2%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20will%20see%20the%20following%20output%20on%20the%20first%20build%20because%20squid%20is%20not%20running%20on%20a%20vm%20in%20the%20vnet.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20azure-arm%3A%20First%20image%20creation%2C%20proxy%20not%20set.%0A%3D%3D%26gt%3B%20azure-arm%3A%20ping%3A%20lsqd.pz.io%3A%20Name%20or%20service%20not%20known%0A%3D%3D%26gt%3B%20azure-arm%3A%20Provisioning%20with%20shell%20script%3A%20%2Ftmp%2Fpacker-shell314489469%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20build%20is%20completed%20you%20will%20see%20the%20following%20output%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3D%3D%26gt%3B%20Builds%20finished.%20The%20artifacts%20of%20successful%20builds%20are%3A%0A--%26gt%3B%20azure-arm%3A%20Azure.ResourceManagement.VMImage%3A%0AOSType%3A%20Linux%0AManagedImageResourceGroupName%3A%20dus2ea1-packer%0AManagedImageName%3A%20Ubuntu_2020_01_25_01_41%0AManagedImageId%3A%20%2Fsubscriptions%2F7d559a72-xxxx-xxxx-xxxx-5ca5b14a25e7%2FresourceGroups%2Fdus2ea1-packer%2Fproviders%2FMicrosoft.Compute%2Fimages%2FUbuntu_2020_01_25_01_41%0AManagedImageLocation%3A%20eastus%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1696374613%22%20id%3D%22toc-hId--1696374613%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22h_2709635791582051641540%22%20id%3D%22toc-hId-791138220%22%20id%3D%22toc-hId-791138220%22%3EBuilding%20Squid%20Proxy%20VMs%3A%3C%2FH4%3E%0A%3CP%3ELets%20build%20out%20the%20%60%3CSTRONG%3Elsqd%3C%2FSTRONG%3E%60%20VM's%20using%20the%20Ubuntu%20image%20we%20just%20built.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EBe%20default%20all%20linux%20boxes%20are%20setup%20to%20use%20a%20ssh_key%20which%20is%20by%20default%20pulled%20from%20%60%3CSTRONG%3E~%2F.ssh%2Fid_rsa.pub%3C%2FSTRONG%3E%60.%26nbsp%3B%20To%20override%20this%20path%2C%20create%20a%20%60%3CSTRONG%3Esecrets.tfvars%3C%2FSTRONG%3E%60%20in%20the%20deployment%20folder%20and%20paste%20%60%3CSTRONG%3Essh_key_path%26nbsp%3B%20%3D%20%22%3CPATH%20to%3D%22%22%20key%3D%22%22%3E%22%3C%2FPATH%3E%3C%2FSTRONG%3E%60%20If%20you%20need%20to%20create%20a%20new%20key%2C%20run%20%60ssh-keygen%60%3C%2FLI%3E%0A%3CLI%3EOpen%20%60%3CSTRONG%3Edeployment.tfvars%3C%2FSTRONG%3E%60%20and%20change%20the%20count%20for%20%60%3CSTRONG%3Elsqd%3C%2FSTRONG%3E%60%20to%20%60%3CSTRONG%3E2%3C%2FSTRONG%3E%60.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3ERun%26nbsp%3B%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%3C%2FLI%3E%0A%3CLI%3EType%20%60%3CSTRONG%3Eyes%3C%2FSTRONG%3E%60%20to%20create%20the%20resources%20for%20the%20squid%20box.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_792001999181582051707596%22%20id%3D%22toc-hId--1016316243%22%20id%3D%22toc-hId--1016316243%22%3EBuilding%20the%20Second%20Packer%20Image%20which%20is%20proxy%20aware%3A%3C%2FH4%3E%0A%3CP%3ENext%20we%20need%20to%20build%20our%20%3CSTRONG%3Esecond%3C%2FSTRONG%3E%20image.%26nbsp%3B%20The%20second%20image%20will%20run%20the%20%60%3CEM%3Epacker%2Fscripts%2Fset_proxy.sh%3C%2FEM%3E%60%20script%20which%20will%20check%20if%20the%20proxy%20servers%20are%20online%20and%20make%20the%20necessary%20proxy%20changes.%3C%2FP%3E%0A%3CP%3ERun%20%60%3CSTRONG%3E.%2Fdeploy.py%20-p%20-po%20ubuntu%20-d%20us2%3C%2FSTRONG%3E%60%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETake%20note%20of%20the%20output%20from%20the%20build%20which%20will%20include%E2%80%A6%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20azure-arm%3A%20Setting%20Proxy...%0A%20%20%20%20azure-arm%3A%20%2Fetc%2Fenvironment...%0A%20%20%20%20azure-arm%3A%20PATH%3D%22%2Fusr%2Flocal%2Fsbin%3A%2Fusr%2Flocal%2Fbin%3A%2Fusr%2Fsbin%3A%2Fusr%2Fbin%3A%2Fsbin%3A%2Fbin%3A%2Fusr%2Fgames%3A%2Fusr%2Flocal%2Fgames%22%0A%20%20%20%20azure-arm%3A%20http_proxy%3D%22http%3A%2F%2Flsqd.pz.io%3A3128%2F%22%0A%20%20%20%20azure-arm%3A%20https_proxy%3D%22https%3A%2F%2Flsqd.pz.io%3A3128%2F%22%0A%20%20%20%20azure-arm%3A%20%2Fetc%2Fapt%2Fapt.conf.d%2Fproxy.conf...%0A%20%20%20%20azure-arm%3A%20Acquire%3A%3Ahttp%3A%3AProxy%20%22http%3A%2F%2Flsqd.pz.io%3A3128%22%3B%0A%20%20%20%20azure-arm%3A%20Acquire%3A%3Ahttps%3A%3AProxy%20%22https%3A%2F%2Flsqd.pz.io%3A3128%22%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_36857769281582051731410%22%20id%3D%22toc-hId-1471196590%22%20id%3D%22toc-hId-1471196590%22%3EBuilding%20Azure%20SQL%20Server%20and%20DB%3A%3C%2FH4%3E%0A%3COL%3E%0A%3CLI%3EOpen%20%60deployment.tfvars%60%20and%20change%20%60%3CSTRONG%3Esql_config_map.myapp.deploy%3C%2FSTRONG%3E%60%20equal%20to%20%60%3CSTRONG%3Etrue%3C%2FSTRONG%3E%60.%26nbsp%3B%20%3CI%3EThe%20sql%20server%20will%20be%20a%20single%20database%20and%20vnet%20support.%20%3C%2FI%3E%3C%2FLI%3E%0A%3CLI%3ERun%26nbsp%3B%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%3C%2FLI%3E%0A%3CLI%3ETake%20note%20that%20the%20%60password%60%20is%20passed%20from%20a%20resource%20in%20terraform.%26nbsp%3B%20Because%20we%20are%20passing%20it%20into%20cloud-init%20at%20another%20step%20in%20plain%20text%20it's%20VERY%20important%20that%20its%20changed.%3CBR%20%2F%3ETerraform%20will%20perform%20the%20following%20actions%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EPlan%3A%204%20to%20add%2C%200%20to%20change%2C%200%20to%20destroy.%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_443450927371582051754149%22%20id%3D%22toc-hId--336257873%22%20id%3D%22toc-hId--336257873%22%3EBuilding%20NodeJS%20VMs%3A%3C%2FH4%3E%0A%3CP%3ELets%20build%20out%20the%20nodejs%20servers.%26nbsp%3B%20Make%20sure%20the%202nd%20packer%20images%20exists%20in%20the%20Packer%20resource%20group.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EOpen%20%60deployment.tfvars%60%20and%20change%20the%20count%20for%20%60%3CSTRONG%3Elnjs%3C%2FSTRONG%3E%60%20to%20%60%3CSTRONG%3E2%3C%2FSTRONG%3E%60.%26nbsp%3B%20%3CI%3EThe%20nodejs%20servers%20will%20be%20deployed%20with%20only%20a%20private%20ip%20and%20put%20behind%20a%20private%20load%20balancer.%3C%2FI%3E%3C%2FLI%3E%0A%3CLI%3ERun%26nbsp%3B%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%3C%2FLI%3E%0A%3CLI%3EThe%20%60%3CSTRONG%3Elnjs%3C%2FSTRONG%3E%60%20vm%20will%20be%20created%20using%20the%20packer%20ubuntu%20image%20we%20created%20in%20a%20previous%20step.%26nbsp%3B%20The%20VM%20itself%20will%20be%20bootstrapped%20by%20a%20cloud-init%20script%20which%20will%20install%20nodejs%20and%20pm2.%26nbsp%3B%20The%20cloud-init%20scripts%20are%20under%20the%20cloud-init%20folder.%20Take%20note%20that%20the%20sql_sa_password%2C%20sql_dns%20is%20passed%20from%20the%20sql_server%20module%20which%20is%20why%20we%20created%20it%20first.%26nbsp%3B%20This%20is%20done%20to%20simplify%20the%20example%2C%20please%20do%20not%20pass%20credentials%20as%20plain%20text%20through%20cloud-init%20in%20production.%26nbsp%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3Ecloud-init%20for%20lnjs%20vm%20with%20simple%20node%20site%3A%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23cloud-config%0Apackage_upgrade%3A%20true%0Apackages%3A%0Awrite_files%3A%0A%20%20-%20owner%3A%20%24%7Badmin_username%7D%3A%24%7Badmin_username%7D%0A%20%20-%20path%3A%20%2Fhome%2F%24%7Badmin_username%7D%2Fmyapp%2Findex.js%0A%20%20%20%20content%3A%20%7C%0A%20%20%20%20%20%20var%20express%20%3D%20require('express')%0A%20%20%20%20%20%20var%20app%20%3D%20express()%0A%20%20%20%20%20%20var%20os%20%3D%20require('os')%3B%0A%20%20%20%20%20%20app.get('%2F'%2C%20function%20(req%2C%20res)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20Connection%20%3D%20require('tedious').Connection%3B%0A%20%20%20%20%20%20%20%20%20%20var%20config%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20server%3A%20'%24%7Bsql_dns%7D'%2C%20%2F%2Fupdate%20me%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20authentication%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20'default'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20options%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20userName%3A%20'sa'%2C%20%2F%2Fupdate%20me%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20password%3A%20'%24%7Bsql_sa_password%7D'%20%2F%2Fupdate%20me%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20%20%20var%20connection%20%3D%20new%20Connection(config)%3B%0A%20%20%20%20%20%20%20%20%20%20connection.on('connect'%2C%20function%20(err)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(err)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20console.log(err)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%20%20%20%7B%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20console.log(%22Connected%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20executeStatement()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20var%20Request%20%3D%20require('tedious').Request%3B%0A%20%20%20%20%20%20%20%20%20%20var%20TYPES%20%3D%20require('tedious').TYPES%3B%0A%20%20%20%20%20%20%20%20%20%20function%20executeStatement()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20request%20%3D%20new%20Request(%22SELECT%20%40%40VERSION%3B%22%2C%20function%20(err)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(err)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20console.log(err)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20result%20%3D%20'Hello%20World%20from%20host1%20'%20%2B%20os.hostname()%20%2B%20'!%20%5Cn'%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20request.on('row'%2C%20function%20(columns)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20columns.forEach(function%20(column)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(column.value%20%3D%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20console.log('NULL')%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%2B%3D%20column.value%20%2B%20%22%20%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20res.send(result)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20result%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20connection.execSql(request)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20app.listen(3000%2C%20function%20()%20%7B%0A%20%20%20%20%20%20%20%20%20%20console.log('Hello%20world%20app%20listening%20on%20port%203000!')%0A%20%20%20%20%20%20%7D)%0Aruncmd%3A%0A%20%20-%20sudo%20curl%20-sL%20https%3A%2F%2Fdeb.nodesource.com%2Fsetup_13.x%20%7C%20sudo%20bash%20-%0A%20%20-%20sudo%20apt%20install%20nodejs%20-y%0A%20%20-%20sudo%20npm%20config%20set%20proxy%20http%3A%2F%2F%24%7Bproxy%7D%3A3128%2F%0A%20%20-%20sudo%20npm%20config%20set%20https-proxy%20http%3A%2F%2F%24%7Bproxy%7D%3A3128%2F%0A%20%20-%20cd%20%22%2Fhome%2F%24%7Badmin_username%7D%2Fmyapp%22%0A%20%20-%20sudo%20npm%20install%20express%20-y%0A%20%20-%20sudo%20npm%20install%20tedious%20-y%0A%20%20-%20sudo%20npm%20install%20-g%20pm2%20-y%0A%20%20-%20sudo%20pm2%20start%20%2Fhome%2F%24%7Badmin_username%7D%2Fmyapp%2Findex.js%0A%20%20-%20sudo%20pm2%20startup%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH4%20id%3D%22h_274585552461582051783801%22%20id%3D%22toc-hId--2143712336%22%20id%3D%22toc-hId--2143712336%22%3EBuilding%20Nginx%20VMs%3A%3C%2FH4%3E%0A%3CP%3ELets%20build%20out%20the%20nginx%20servers.%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EOpen%20%60deployment.tfvars%60%20and%20change%20the%20count%20for%20%60%3CSTRONG%3Elngx%3C%2FSTRONG%3E%60%20to%20%60%3CSTRONG%3E2%3C%2FSTRONG%3E%60.%26nbsp%3B%20%3CI%3EThe%20lngx%20servers%20will%20be%20deployed%20with%20only%20a%20private%20ip%20and%20put%20behind%20a%20public%20load%20balancer.%3C%2FI%3E%3C%2FLI%3E%0A%3CLI%3ERun%26nbsp%3B%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%3C%2FLI%3E%0A%3CLI%3EThe%20%60lngx%60%20vm%20will%20be%20created%20using%20the%20packer%20ubuntu%20image%20we%20created%20in%20a%20previous%20step.%26nbsp%3B%20The%20VM%20itself%20will%20be%20bootstrapped%20by%20a%20cloud-init%20script%20which%20will%20install%20nginx.%26nbsp%3B%20The%20cloud-init%20scripts%20are%20under%20the%20cloud-init%20folder.%20Take%20note%20that%20the%20%60njs_lb_dns%60%20is%20passed%20from%20the%20%60lnjs%60%26nbsp%3B%20module%20which%20we%20created%20in%20the%20previous%20step.%26nbsp%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3Ecloud-init%20example%3A%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23cloud-config%0Apackage_upgrade%3A%20true%0Apackages%3A%0A%20%20-%20nginx%0Awrite_files%3A%0A%20%20-%20owner%3A%20www-data%3Awww-data%0A%20%20-%20path%3A%20%2Fetc%2Fnginx%2Fsites-available%2Fdefault%0A%20%20%20%20content%3A%20%7C%0A%20%20%20%20%20%20server%20%7B%0A%20%20%20%20%20%20%20%20listen%2080%3B%0A%20%20%20%20%20%20%20%20location%20%2F%20%7B%0A%20%20%20%20%20%20%20%20%20%20proxy_pass%20http%3A%2F%2F%24%7Bnjs_lb_dns%7D%3A3000%3B%0A%20%20%20%20%20%20%20%20%20%20proxy_http_version%201.1%3B%0A%20%20%20%20%20%20%20%20%20%20proxy_set_header%20Upgrade%20%24http_upgrade%3B%0A%20%20%20%20%20%20%20%20%20%20proxy_set_header%20Connection%20keep-alive%3B%0A%20%20%20%20%20%20%20%20%20%20proxy_set_header%20Host%20%24host%3B%0A%20%20%20%20%20%20%20%20%20%20proxy_cache_bypass%20%24http_upgrade%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0Aruncmd%3A%0A%20%20-%20service%20nginx%20restart%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH4%20id%3D%22toc-hId-343800497%22%20id%3D%22toc-hId-343800497%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22h_480379056551582051801936%22%20id%3D%22toc-hId--765492025%22%20id%3D%22toc-hId--765492025%22%3EEnabling%20the%20secondary%20region%20(optional)%3A%3C%2FH4%3E%0A%3CP%3EFor%20the%20next%20apply%20lets%20enable%20the%20secondary%20region%20which%20will%20deploy%20another%20vnet%20and%20create%20peerings%20on%20both%20ends.%26nbsp%3B%20Open%20%60deployment.tfvars%60%20and%20change%20%60%3CSTRONG%3Eenable_secondary%20%3D%20true%3C%2FSTRONG%3E%60.%3CBR%20%2F%3ERun%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CI%3EIf%20you%20get%20an%20error%2C%20just%20run%20the%20plan%20again.%26nbsp%3B%20Occasionally%20a%20resource%20creation%20is%20attempted%20before%20its%20resource%20group%20is%20created.%20%3C%2FI%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_480379056551582051801936%22%20id%3D%22toc-hId-1722020808%22%20id%3D%22toc-hId-1722020808%22%3EEnable%20Log%20Analytics%20(optional)%3A%3C%2FH4%3E%0A%3CP%3EYou%20can%20enable%20log%20analytics%20for%20your%20deployment%20by%20opening%20%60deployment.tfvars%60%20and%20change%2Fadd%20%60%3CSTRONG%3Eenable_log_analytics%20%3D%20true%3C%2FSTRONG%3E%60.%3CBR%20%2F%3ERun%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%3C%2FSTRONG%3E%60%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CI%3EAny%20VM's%20you%20have%20will%20get%20a%20extension%20added%20which%20will%20auto%20install%20the%20OMS%20agent%20and%20configure%20it%20to%20the%20log%20analytics%20instance.%20%3CBR%20%2F%3E%3C%2FI%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22h_480379056551582051801936%22%20id%3D%22toc-hId--85433655%22%20id%3D%22toc-hId--85433655%22%3EEnable%20Remote%20State%20(optional)%3A%3C%2FH4%3E%0A%3CP%3ESo%20far%20your%20state%20has%20been%20local%20only%20which%20can%20be%20found%20deployments%2F%3CDEPLOYMENT%20code%3D%22%22%3E%2Fstate.%20State%20should%20be%20checked%20into%20source%20control%20but%20first%20should%20be%20encrypted%20as%20it%20may%20contain%20senstive%20keys%20from%20resources.%26nbsp%3B%20The%20other%20option%20is%20to%20store%20the%20state%20in%20a%20blob%20storage%20account%20by%20following%20the%20below%20steps.%26nbsp%3B%20This%20can%20be%20a%20bit%20tricky%20as%20we%20need%20to%20play%20a%20bit%20of%20chicken%20n%20egg.%26nbsp%3B%3C%2FDEPLOYMENT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20enable%20remote%20state%20for%20your%20deployment%20by%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EOpen%20%60deploy.py%60%20and%20change%20%3CSTRONG%3EREMOTE_STATE_BYPASS%20%3D%20True%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EOpen%20%60deployment.tfvars%60%20and%20change%2Fadd%20%60%3CSTRONG%3Eenable_remote_state%20%3D%20true%3C%2FSTRONG%3E%60%3C%2FLI%3E%0A%3CLI%3ERun%20and%20apply%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%20-a%20apply%20-t%20remote_state.tf%3C%2FSTRONG%3E%60%26nbsp%3B%20to%20deploy%20the%20remote%20state%20core%20resources.%3C%2FLI%3E%0A%3CLI%3ELook%20at%20the%20output%20for%20the%20following%20command%2C%20run%20it%20once%20the%20above%20apply%20is%20complete.%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ERun%20the%20following%20command%20after%20the%20next%20apply%3A%0Aaz%20storage%20blob%20upload%20-f%2Fmnt%2Fc%2FProjects%2Fterraform-eiac%2Fterraform%2Fazure%2Fdeployments%2Fus2%2Fstate%2Fmain%2Fterraform.tfstate%20-c%20main%20-n%20terraform.tfstate%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3CLI%3EOpen%20%60deploy.py%60%20and%20change%20%3CSTRONG%3EREMOTE_STATE_BYPASS%20%3D%20False%3C%2FSTRONG%3E%20%3C%2FLI%3E%0A%3CLI%3EOpen%20'deploy.py'%20and%20change%20%3CSTRONG%3EUPLOAD_STATE_TO_REMOTE%20%3D%20True%20%3C%2FSTRONG%3Eto%20auto%20upload%20the%20local%20state%20file%20to%20the%20remote%20container%20on%20next%20plan%3C%2FLI%3E%0A%3CLI%3ERun%20a%20plan%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%60%20%3C%2FSTRONG%3Ewhich%20should%20show%20the%20following%20in%20the%20output%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EStart%20remote%20state%20engine...%20Will%20take%20a%20few%20seconds...%0AUploading%20State%20file%20to%20Remote%20State%20Container...%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3CLI%3EChange%20%3CSTRONG%3EUPLOAD_STATE_TO_REMOTE%20%3D%20False%20%3C%2FSTRONG%3Eand%20run%20%60%3CSTRONG%3E.%2Fdeploy.py%20-d%20us2%60.%26nbsp%3B%20%3C%2FSTRONG%3EView%20the%20terminal%20output%20and%20verify%20that%20State%20is%20still%20using%20the%20remote%20engine.%26nbsp%3B%26nbsp%3B%20Every%20state%20modification%20will%20not%20result%20in%20a%20blob%20snapshot%20which%20will%20allow%20you%20to%20easily%20rollback.%3C%2FLI%3E%0A%3CLI%3EOnce%20you%20have%20verified%20that%20remote%20state%20is%20being%20used%20you%20can%20backup%20the%20state%20folder%20under%20the%20deployment%20folder%20and%20then%20remove%20it.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%60%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1179536%22%20slang%3D%22en-US%22%3E%3CP%3EWant%20to%20learn%20on%20how%20you%20can%20structure%20a%20Terraform%20project%20to%20deploy%20the%20same%20code%20to%201%3AN%20environments.%26nbsp%3B%20Clone%20the%20repo%20and%20follow%20these%20steps...%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22high%20level.png%22%20style%3D%22width%3A%20355px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171775i4C527641ABAAC72F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22high%20level.png%22%20alt%3D%22high%20level.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1179536%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Part 1:  The Project

Part 2: Deploy Wrapper Overview

Part 3: Deploying the first environment

 

This is an example of how you could begin to structure your terraform project to deploy the same terraform code to multiple customers, environments or regions.  The project will also give you consist naming across all your resources in a given deployment.  We will not be able to cover all of the options in this project but will cover the basics to get you started.  By no means should this project be deployed without modification to include security, monitoring and other key components to harden your environment.    

 

*** Project is written in Terraform v12

*** Users should have a general understanding of Terraform HCL

*** This is an example / guide not a production ready template.    

 

What is being built:

 

In this example we will deploy 2 squid proxy servers for outbound traffic, 2 nginx servers in front of a public load balancer, 2 nodejs web servers in front of a private load balancer and a single Azure SQL Database with service tunneling enabled.  All DNS resolution will be through Azure Private DNS zones which is configured when building the base image using Packer.  The nginx servers will act as the frontend which will route traffic to a private LB in front of the nodejs app which connects to the Azure SQL Server all of which is configured on deploy through cloud-init.  SSH access will be disabled remotely and is only allowed via Azure Bastion.

 

diagram.png

The Project

The repo (clone)

git clone https://github.com/rohrerb/terraform-eiac.git 


View the project online > https://github.com/rohrerb/terraform-eiac/

 

*Feel free to contribute or give feedback directly on the repo.

Overview of the Project

High Level Project:

high level.png

Level

Additional Information

terraform/azure

This level is referred to as the cloud level which is defaulted as azure in deploy.py

terraform/azure/deployments

Contains terraform variable files for different isolated deployments.  These variable files are fed into the section (main) and drive naming, configuration…

terraform/azure/main

"Main" is also called a section in the deploy.py.  Each section gets its own terraform state file (local or remote).  You can have as many sections as possible and use terraform data sources to related resources between them.  Deployment variable files are shared across all sections.  An example of this could be to have a "main" sections for all things and a "NSG" section for only NSG rules (subnet, NIC, etc). 

terraform/azure/modules

Terraform modules which can reused and referenced across any section.  There is a marketplace with modules or you can write your own like I did.

terraform/azure/packer

Contains packer deployment and os files used to build images.  Deployment files are auto generated based on first run terraform run of "main"

terraform/deploy,py

Python3 wrapper script which is used to control terraform / packer executions. 

README.md

In depth instructions with common deploy.py terraform / packer commands

 

Deployment:

Level

Additional Information

azure/deployments

Contains terraform variable files for different isolated deployments.  These variable files are fed into the section (main) and drive naming, configuration…

azure/deployments/<folder>

<folder(s)> under deployments ultimately act as a deployment or separate environment.  In my example US1 has configured for USGov and US2 is configured for a US Commercial deployment.

azure/deployments/<folder>/deployment.tfvars

This is the variable file which is passed into the "main" section and drives the configuration for the environment.

azure/deployments/<folder>/secrets.tfvars

This is the variable file which is passed into the "main" section and drives the configuration for the environment along with deployment.tfvars except this one is excluded in any commits using .gitignore. 

azure/deployments/<folder>/state/main

If using local state the state file will be deployed in this folder.  Deploy.py also will keep a 30 day rolling backup of state in this folder.  If your using remote state this folder will not exist.

 

Main:

main.png

 

Level

Additional Information

azure/main

"Main" is also called a section in the deploy.py.  Each section gets its own terraform state file (local or remote).  You can have as many sections as possible and use terraform data sources to related resources between them.  Deployment variable files are shared across all sections.  An example of this could be to have a "main" sections for all things and a "NSG" section for only NSG rules (subnet, NIC, etc). 

azure/main/.terraform

Folder which is created by terraform.  Contains providers, module information as well as backend state metadata.

azure/main/cloud-init/<vm_type>_cloudconfig.tpl

Cloud-init folder contains vm type specific cloud-init tpl files. If no file exists for a vm type the VM will not have a value in "custom_data".

azure/main/backend.tf

Target backend which is ultimately controlled by `deploy.py`  Backend config values are added to the command line.

azure/main/data.tf

Contains any high level `data` terraform resources.

azure/main/images.tf

Holds multiple azurerm_image resources which pull packer images from a resource group.

azure/main/locals.tf

Local values which are used in the root module (main).

azure/main/network.tf

Contains network, subnet, watcher and a few other network related resources.

azure/main/packer.tf

Local File resource which is used to write the packer configuration files.

azure/main/provider.tf

Target provider resource.

azure/main/recovery_vault.tf

Azure Site recovery terraform resources which are used to protect VMs in a secondary region.

azure/main/remote_state.tf

Project allows you to have a local state or a remote state.  This file contains the resources required to host state in a blob storage account.  100% driven by a variable.

azure/main/sql_server.tf

Contains the resources to deploy Azure SQL Databases and related resources. 

azure/main/resource_groups.tf

Contains multiple resource group terraform resources to hold the many resources created by this project.

azure/main/variables.tf

Variables used in the deployment in the root module.

azure/main/vm_lngx.tf

Example of a VM type instance.  `vm_` is just a prefix to keep them together.  `lngx` first character `l` for linux and `sql` to describe what workload the vm is running.

azure/main/vm_lsqd.tf

Example of a VM type instance.  `vm_` is just a prefix to keep them together.  `lsqd` first character `l` for linux and `web` to describe what workload the vm is running.

 

Main:

main_modules.png

 

Level

Additional Information

azure/main/modules

This folder contains custom modules which are leveraged within the root module (main).   There is a large registry of modules already built which can be pulled in. https://registry.terraform.io/browse/modules?provider=azurerm

 

Packer:

packer.png

 

Level

Additional Information

azure/packer/deployments

This folder contains deployment.json files for each terraform deployment.  These files are 100% dynamically created by azure/main/packer.tf

azure/packer/os
 

This folder contains the different os specific packer files which are used in the deploy.py script.   Any changes to the provisioners will affected the base images which all VM's are created from. Specific VM type modifications should be made using cloud-init.

 

Naming Conventions:

 

Deploying using the template will provide a consisting naming convention across your environments.  The deployment.tfvars file contains several variables which will drive your resource naming.

 

environment_code        = "d"       #Environment Code (d = dev, q = qa, p = prod, etc)

deployment_code         = "us2"    #Deployment Code (CountryCode plus a number usually a iterator)

location_code           = "ea1"         #Location Code (Location of the region / DC plus number usually a iterator)

location_code_secondary = "we1"         #Location Code for Secondary Region (Location of the region / DC plus number usually a iterator)

 

Most resources are prefixed using full environment code (above) which is made up of

environment_code + deployment_code + location_code

Example of resource groups names using the above values.

 

rg_deployment.png

 

Configuration Options:

 

Below are some of the variable options available per deployment.tfvars

 

Variable

Example Value

Required

Description

subscription_id

"7d559a72-c8b6-4d07-9ec0-5ca5b14a25e7"

Yes

Subscription which all resources will be deployed into.  User deploying must have access to this subscription.

enable_remote_state

false

Yes

If enabled a new Resource Group, Storage account, Container will be created to hold the terraform state remotely. Additional steps will be required and are listed in a later blog post.

enable_secondary

true

No

If enabled a few other variables would be required, such as location_secondary, location_code_secondary .  It will build out this skeleton deployment in a secondary region for DR purposes which includes additional resource groups, vnet, etc.

location

"East US"

Yes

Region where all resources are deployed.

location_secondary

"West US"

No

Required if enable_secondary is enabled.  This drives the region where the secondary resources are placed.

network_octets

"10.3"

Yes

First two network octets for the VNET.  Be default the VNET is configured with a /16 space.  By default you get DMZ, Services, Data, Management and AzureBastion Subnets.  These can be changed under the subnet variable in the variables.tf file.

network_octets_secondary

"10.4

No

Required if enable_secondary is enabled. First two network octets for the secondary VNET.  Be default the VNET is configured with a /16 space.

enable_recovery_services

true

No

In enabled the resources are deployed to enable Azure Site Recovery to the secondary region.  The secondary region needs to be configured to enable this.

enable_bastion

true

No

If enabled the key components for Bastion Host will be added.

deploy_using_zones

True

No

If enabled and the region supports Zones the VM, LB, Public IP's will be deployed across 3 zones.  If disabled the VM's will be deployed within a AVSET.

dns_servers

[10.3.1.6, 10.3.1.7]

No

Private Zones are created by default but you can override by specifying your own DNS servers.

vm_instance_map

{} #See below

Yes

A map which is used to deploy certain VM types in this deployment.  See VM Configuration Options below.

sql_config_map

{}

No

A map which is used to deploy 1:N Azure SQL Servers.  See SQL Server Configuration Options below.

 

VM Configuration Options:

 

Of course this project can be expanded to include Azure resource such as Web Apps, Functions, Logic Apps, etc but out of the box it includes VM's.  VM's are controlled by a single map in the environment.tfvars.

 

All VM's are by default configured to use bastion host to ssh or RDP.  If you wish to override you will need to add a public ip to the VM's and open the NSG.

 

vm_instance_maps = {
  lngx = { count = 2, size = "Standard_D2s_v3", os_disk_size = 30, data_disk_count = 1, data_disk_size = 5, enable_recovery = false, enable_public_ip = false, enable_vm_diagnostics = false }
  lnjs = { count = 0, size = "Standard_D2s_v3", os_disk_size = 30, data_disk_count = 2, data_disk_size = 5 }
}

 

The above vm instance map would deploy these resources in the dmz subnet and rg with the following naming convention which are derived from

`environment_code` + `deployment_code` + `location_code` + `vm_code` + `iterator`

Breaddown of the `vm_instance_map` options for each entry (vm type):

lngx = { count = 2, size = "Standard_D2s_v3", os_disk_size = 30, data_disk_count = 1, data_disk_size = 5, enable_recovery = false, enable_public_ip = false, enable_vm_diagnostics = false }

 

Attritbute

Example Value

Required

Description

Map Key

lngx

Yes

Map Key which maps to the `location_code` + `instance_type` of the VM

count

2

Yes

Number of VM's you want to create of this type.

size

Standard_D2s_v3

Yes

Size that you want each of the VMs of this type to have.  You can use to lookup available sizes http://www.azureinstances.info/ as well as Azure CLI, etc.

os_disk_size

30

Yes

Size in GB of the OS Disk of this VM type.

data_disk_count

1

No

Number of Data Disks to create and attach to the VM

data_disk_size

50

No

Size in GB of the Data Disks

enable_public_ip

true

No

If enabled a public ip will be created and attached to each of the VM's nic's

enable_vm_diagnostics

false

No

If enabled a storage account will be created and configured for this VM type as well as enabling diagnostics for the VM.

enable_recovery

False

No

If enabled the VM and all disks will be protected by Recovery Services.  `enable_secondary` and `enable_recovery_services` must be enabled in the deployment as well. 

 

SQL Server Configuration Options:

 

Each high level map will get you a single SQL Server instance with 1:N SQL Databases. 

 

myapp = {
    deploy = true
    server_name = "main"
    admin_user = "sadmin"
    subnet_vnet_access = {
      app =  { }
    }
    firewall_rules = {
      all =  { start_ip_address = "0.0.0.0", end_ip_address = "255.255.255.255" } //This is here as a example, please don't do this.
    }
    databases = {
      main = { edition = "Standard", size = "S0" }
      qa = { edition = "Standard", size = "S2" }
    }
  }

 

 

Attritbute

Example Value

Required

Description

map Key

mapp

Yes

Map Key which is used to derive the name of the sql resources

deploy

true

Yes

Switch used to control the creation of the resources.

admin_user

sadmin

Yes

Username for the SQL Admin user.

subnet_vnet_access

app =  { }

No

Map list which will allow traffic from a subnet to flow to the SQL privately.

firewall_rules

 all =  { start_ip_address = "0.0.0.0", end_ip_address = "255.255.255.255" }

No

Map list of firewall rules to add to the sql server. 

databases

 main = { edition = "Standard", size = "S0" }

      qa = { edition = "Standard", size = "S2" }

Yes

Map list of the databases to create under this sql server resources.   Map key is the name of the database, edition and size are required.

 

Deploy Wrapper Overview

If using this project you should always use the deploy.py to manipulate the terraform environment.  It handles wiring up all paths to variables, state as well as the backend configurations for local and remote state.   In addition the wrapper handles switching cloud and changing accounts automatically based on terraform variables in the deployment.tfvars.

 

If you are using windows, please go through these steps to install Terraform on the Window 10 Linux Sub System.  You also need to install Packer, please install the same way you installed Terraform.

 

Next we need to install python3 and pip3

 

sudo apt-get update
sudo apt-get install python3
sudo apt-get install python3-pip
pip3 install colorama

 

The wrapper has a detailed README.md that can help you with command help as well as example commands for terraform and packer.

 

deploy.py --help
usage: deploy.py [-h] -d DEPLOUMENT [-c CLOUD] [-s SECTION]
                 [-a [ACTION [ACTION ...]]] [-t TARGET] [-r RESOURCE] [-v]
                 [-pu] [-us UNLOCK_STATE] [-ss STATE_SNAPSHOT] [-p]
                 [-po PACKER_OS]

Run Terraform Wrapper

optional arguments:
  -h, --help            show this help message and exit

required deployment commands:

  -d DEPLOUMENT, --deploument DEPLOUMENT
                        Target Deployment to Terraform against

optional enviornment commands:

  -c CLOUD, --cloud CLOUD
                        Cloud to Target

  -s SECTION, --section SECTION
                        Section to target (usefull for large projects when
                        state is broken into multiple files.)

  -a [ACTION [ACTION ...]], --action [ACTION [ACTION ...]]
                        Available terraform actions; plan, apply, taint,
                        untaint, state, import

  -t TARGET, --target TARGET
                        Specify specific modules for the selected --action

  -r RESOURCE, --resource RESOURCE
                        ResourceID which is used if doing a state import.

  -v, --verbose         Show verbose outputs

optional terraform commands:
  -pu, --plugin_update  Specify this parameter if you wish to upgrade/validate
                        terraform plugins

  -us UNLOCK_STATE, --unlock_state UNLOCK_STATE
                        Use this command to unlock state, --unlock_state
                        <lock_id>

  -ss STATE_SNAPSHOT, --state_snapshot STATE_SNAPSHOT
                        Default enabled will take a snapshot of the state on
                        any action except plan.

optional packer commands:

  -p, --packer          Specify this parameter along with -d to run a packer
                        build in a deployment
  -po PACKER_OS, --packer_os PACKER_OS
                        Specify this parameter if -p is used. Available
                        options are under /packer/os/<filename>

 

 

Reviewing the Commands:

Argument

Example Value

Required

Description

-d

us1

Yes

Matches the deployment folders in the terraform project structure. `azure/deployments/<deployment_code>`

-s

main

no

"main" (default) is also called a section in the terraform project structure. `azure/main`  Each section gets its own terraform state file (local or remote).  You can have as many sections as possible and use terraform data sources to related resources between them.  Deployment variable files are shared across all sections.  An example of this could be to have a "main" sections for all things and a "NSG" section for only NSG rules (subnet, NIC, etc).

-a

plan

No

Maps to terraform commands (plan, apply, state, etc) > https://www.terraform.io/docs/commands/index.html.   Plan is the default.

-t

module.rg-test.azurerm_resource_group.rg[0]

No

Required when certain actions are used.  Use target when you want to perform a action on only a few isolated resources. https://www.terraform.io/docs/commands/plan.html#resource-targeting

-r

/subscriptions/7d559a72-c8b6-4d07-9ec0-5ca5b14a25e7/resourceGroups/dus2ea1-dmz

No

Required when importing resources into state.  https://www.terraform.io/docs/import/index.html

-pu

 

No

When used the following is added to `terraform init`  `-get=true -get-plugins=true -upgrade=true'.  Used when you want to upgrade the providers, however its best practice to pin providers in the provider.tf.

-us

--unlock_state 047c2e42-69b7-4006-68a5-573ad93a769a

No

If you are using remote state you may occasionally end up with a lock on the state blob.  To release the lock you can use this parameter or you can release from the azure portal.

--ss

 

No

Default is True, Set to False if you wish to NOT take a snapshot.  I do not recommend that you disable.

-p

 

No

Use -p to enable a Packer run

-po

ubuntu

Yes

Required when -p is added.  Maps to a os file under `azure/packer/os/<filename>

 

Example Commands:

 

 plan

deploy.py -d us1

 

apply

deploy.py -d us1 -a apply

 

apply w/target

deploy.py -d us1 -a apply -t module.rg-test.azurerm_resource_group.rg[0]

 

apply w/target(s)

deploy.py -d us1 -a apply -t module.rg-test.azurerm_resource_group.rg[0] -t module.rg-test.azurerm_resource_group.rg["test"]

 

apply w/target against a tf file. 

deploy.py -d us1  -t resource_groups.tf

 

state remove

deploy.py -d us1 -a state rm -t module.rg-test.azurerm_resource_group.rg[0]

 

state mv

deploy.py -d us1 -a state mv -t module.rg-test.azurerm_resource_group.rg[0] -t module.rg-test2.azurerm_resource_group.rg[0]

 

import

deploy.py -d us1 -a import -t module.rg-test.azurerm_resource_group.rg[0] -r /subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/DUS1VA1-test

 

taint

deploy.py -d us1 -a taint -t null_resource.image

 

untaint

deploy.py -d us1 -a untaint -t null_resource.image

 

unlock a remote state file

If you receive this message you can unlock using the below command. Grab the *ID* under *Lock Info:*

 

Error: Error locking state: Error acquiring the state lock: storage: service returned error: StatusCode=409, ErrorCode=LeaseAlreadyPresent, ErrorMessage=There is already a lease present.
RequestId:9c61c2f1-c01e-00d7-7ec1-c570f5000000
Time:2020-01-08T01:18:23.2626686Z, RequestInitiated=Wed, 08 Jan 2020 01:18:23 GMT, RequestId=9c61c2f1-c01e-00d7-7ec1-c570f5000000, API Version=2018-03-28, QueryParameterName=, QueryParameterValue=

Lock Info:
  ID:        047c2e42-69b7-4006-68a5-573ad93a769a
  Path:      main/terraform.tfstate
  Operation: OperationTypeApply
  Who:       user@machine_xyz
  Version:   0.12.18
  Created:   2020-01-08 01:13:13.1965322 +0000 UTC
  Info:   

 

deploy.py -d us1 --unlock_state 047c2e42-69b7-4006-68a5-573ad93a769a

 

Common Packer Commands:

 

 build ubuntu

deploy.py -p -po ubuntu -d us1

 

build centos

deploy.py -p -po centos -d us1

 

 build windows

deploy.py -p -po windows -d us1

Deploying the first environment

 

Deploying Core Resources:

  1. Open the vscode then File > Open Folder > Choose the root folder which was cloned.
  2. The project is default setup with two deployments:
    • `us1` which is setup for US Government
    • `us2` which is setup for US Commercial
  3. We will continue with us2 as our deployment.  Open the `deployment.tfvars` under `us2` folder, plug your subscription guid in the empty quotes. (Save)
  4. Click Terminal > New Terminal.  (If on windows, type bash and hit enter in the terminal to enter WSL).
  5. Type `cd terraform` so that deploy.py is in your current directory.
  6. Type `./deploy.py -d us2 -pu -t resource_groups.tf -a apply` to run a apply targeting all of the resource groups.  When prompted type `yes` and then enter.  Take note of the commands which show in yellow (after Running:), they are the actual commands which are run to bootstrap the environment (az, tf init/command)
    Runtime Variables:
             Cloud: azure
             Section: main
             Deployment: us2
             Action: apply
             Variables: /mnt/c/Projects/thebarn/eiac/terraform/azure/deployments/us2/deployment.tfvars
             Secrets: /mnt/c/Projects/thebarn/eiac/terraform/azure/deployments/us2/secrets.tfvars
             Section: /mnt/c/Projects/thebarn/eiac/terraform/azure/main
             Deployment: /mnt/c/Projects/thebarn/eiac/terraform/azure/deployments/us2
             Target(s):
                    module.rg-dmz
                    module.rg-services
                    module.rg-management
                    module.rg-data
                    module.rg-network
                    module.rg-network-secondary
                    module.rg-packer
                    module.rg-recovery-vault
    
    Running: az cloud set --name AzureCloud
    Running: az account set -s 7d559a72-xxxx-xxxx-xxxx-5ca5b14a25e7
    Start local state engine...
    Running: terraform init -reconfigure -get=true -get-plugins=true -upgrade=true -verify-plugins=true
    ...
    Terraform has been successfully initialized!
    …
    Taking state snapshot
    Running: terraform apply -target=module.rg-dmz -target=module.rg-services -target=module.rg-management -target=module.rg-data -target=module.rg-network -target=module.rg-network-secondary -target=module.rg-packer -target=module.rg-recovery-vault -state=/mnt/c/Projects/thebarn/eiac/terraform/azure/deployments/us2/state/main/terraform.tfstate -var-file=/mnt/c/Projects/thebarn/eiac/terraform/azure/deployments/us2/deployment.tfvars -var-file=/mnt/c/Projects/thebarn/eiac/terraform/azure/deployments/us2/secrets.tfvars
    ...
     
    Terraform will perform the following actions:
      # module.rg-data.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "eastus"
          + name     = "dus2ea1-data"
          + tags     = (known after apply)
        }
    
      # module.rg-dmz.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "eastus"
          + name     = "dus2ea1-dmz"
          + tags     = (known after apply)
        }
    
      # module.rg-management.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "eastus"
          + name     = "dus2ea1-management"
          + tags     = (known after apply)
        }
    
      # module.rg-network.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "eastus"
          + name     = "dus2ea1-network"
          + tags     = (known after apply)
        }
    
      # module.rg-packer.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "eastus"
          + name     = "dus2ea1-packer"
          + tags     = (known after apply)
        }
    
      # module.rg-recovery-vault.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "westus"
          + name     = "dus2we1-recovery-vault"
          + tags     = (known after apply)
        }
    
      # module.rg-services.azurerm_resource_group.rg[0] will be created
      + resource "azurerm_resource_group" "rg" {
          + id       = (known after apply)
          + location = "eastus"
          + name     = "dus2ea1-services"
          + tags     = (known after apply)
        }
    
    Plan: 7 to add, 0 to change, 0 to destroy.​
  7. Type `./deploy.py -d us2 -a apply` to apply the rest of the initial resources (network, Bastion, Watcher, etc)
        ...
    Plan: 22 to add, 0 to change, 0 to destroy.​

 

Building First Packer Image:

Next we need to build our first image, we will focus on only Ubuntu.  This first image will be solely used to build out the `lsqd` VM's which will be our proxy (squid) VM's. During our 2nd apply the packer configuration for us2 was written to the packer deployment folder.

*The first time you deploy packer it will require you to authenticate twice.   Once the image is built it will land in the `dus2ea1-packer` resource group.

./deploy.py -p -po ubuntu -d us2

 

You will see the following output on the first build because squid is not running on a vm in the vnet.

 

    azure-arm: First image creation, proxy not set.
==> azure-arm: ping: lsqd.pz.io: Name or service not known
==> azure-arm: Provisioning with shell script: /tmp/packer-shell314489469

 

Once the build is completed you will see the following output:

 

==> Builds finished. The artifacts of successful builds are:
--> azure-arm: Azure.ResourceManagement.VMImage:
OSType: Linux
ManagedImageResourceGroupName: dus2ea1-packer
ManagedImageName: Ubuntu_2020_01_25_01_41
ManagedImageId: /subscriptions/7d559a72-xxxx-xxxx-xxxx-5ca5b14a25e7/resourceGroups/dus2ea1-packer/providers/Microsoft.Compute/images/Ubuntu_2020_01_25_01_41
ManagedImageLocation: eastus

 

 

Building Squid Proxy VMs:

Lets build out the `lsqd` VM's using the Ubuntu image we just built.  

  1. Be default all linux boxes are setup to use a ssh_key which is by default pulled from `~/.ssh/id_rsa.pub`.  To override this path, create a `secrets.tfvars` in the deployment folder and paste `ssh_key_path  = "<path to key>"` If you need to create a new key, run `ssh-keygen`
  2. Open `deployment.tfvars` and change the count for `lsqd` to `2`. 
  3. Run  `./deploy.py -d us2 -a apply`
  4. Type `yes` to create the resources for the squid box.

 

Building the Second Packer Image which is proxy aware:

Next we need to build our second image.  The second image will run the `packer/scripts/set_proxy.sh` script which will check if the proxy servers are online and make the necessary proxy changes.

Run `./deploy.py -p -po ubuntu -d us2`

 

Take note of the output from the build which will include…

 

    azure-arm: Setting Proxy...
    azure-arm: /etc/environment...
    azure-arm: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    azure-arm: http_proxy="http://lsqd.pz.io:3128/"
    azure-arm: https_proxy="https://lsqd.pz.io:3128/"
    azure-arm: /etc/apt/apt.conf.d/proxy.conf...
    azure-arm: Acquire::http::Proxy "http://lsqd.pz.io:3128";
    azure-arm: Acquire::https::Proxy "https://lsqd.pz.io:3128";

 

 

Building Azure SQL Server and DB:

  1. Open `deployment.tfvars` and change `sql_config_map.myapp.deploy` equal to `true`.  The sql server will be a single database and vnet support.
  2. Run  `./deploy.py -d us2 -a apply`
  3. Take note that the `password` is passed from a resource in terraform.  Because we are passing it into cloud-init at another step in plain text it's VERY important that its changed.
    Terraform will perform the following actions:

 

Plan: 4 to add, 0 to change, 0 to destroy.

 

 

Building NodeJS VMs:

Lets build out the nodejs servers.  Make sure the 2nd packer images exists in the Packer resource group.

  1. Open `deployment.tfvars` and change the count for `lnjs` to `2`.  The nodejs servers will be deployed with only a private ip and put behind a private load balancer.
  2. Run  `./deploy.py -d us2 -a apply`
  3. The `lnjs` vm will be created using the packer ubuntu image we created in a previous step.  The VM itself will be bootstrapped by a cloud-init script which will install nodejs and pm2.  The cloud-init scripts are under the cloud-init folder. Take note that the sql_sa_password, sql_dns is passed from the sql_server module which is why we created it first.  This is done to simplify the example, please do not pass credentials as plain text through cloud-init in production. 

    cloud-init for lnjs vm with simple node site:
    #cloud-config
    package_upgrade: true
    packages:
    write_files:
      - owner: ${admin_username}:${admin_username}
      - path: /home/${admin_username}/myapp/index.js
        content: |
          var express = require('express')
          var app = express()
          var os = require('os');
          app.get('/', function (req, res) {
              var Connection = require('tedious').Connection;
              var config = {
                  server: '${sql_dns}', //update me
                  authentication: {
                      type: 'default',
                      options: {
                          userName: 'sa', //update me
                          password: '${sql_sa_password}' //update me
                      }
                  }
              };
              var connection = new Connection(config);
              connection.on('connect', function (err) {
                  if (err) {
                      console.log(err);
                  }  
                  else    {  
                    console.log("Connected");
                    executeStatement();
                  }
              });
              var Request = require('tedious').Request;
              var TYPES = require('tedious').TYPES;
              function executeStatement() {
                  request = new Request("SELECT @@VERSION;", function (err) {
                      if (err) {
                          console.log(err);
                      }
                  });
                  var result = 'Hello World from host1 ' + os.hostname() + '! \n';
                  request.on('row', function (columns) {
                      columns.forEach(function (column) {
                          if (column.value === null) {
                              console.log('NULL');
                          } else {
                              result += column.value + " ";
                          }
                      });
                      res.send(result);
                      result = "";
                  });
                  connection.execSql(request);
              }
          });
          app.listen(3000, function () {
              console.log('Hello world app listening on port 3000!')
          })
    runcmd:
      - sudo curl -sL https://deb.nodesource.com/setup_13.x | sudo bash -
      - sudo apt install nodejs -y
      - sudo npm config set proxy http://${proxy}:3128/
      - sudo npm config set https-proxy http://${proxy}:3128/
      - cd "/home/${admin_username}/myapp"
      - sudo npm install express -y
      - sudo npm install tedious -y
      - sudo npm install -g pm2 -y
      - sudo pm2 start /home/${admin_username}/myapp/index.js
      - sudo pm2 startup​

Building Nginx VMs:

Lets build out the nginx servers. 

  1. Open `deployment.tfvars` and change the count for `lngx` to `2`.  The lngx servers will be deployed with only a private ip and put behind a public load balancer.
  2. Run  `./deploy.py -d us2 -a apply`
  3. The `lngx` vm will be created using the packer ubuntu image we created in a previous step.  The VM itself will be bootstrapped by a cloud-init script which will install nginx.  The cloud-init scripts are under the cloud-init folder. Take note that the `njs_lb_dns` is passed from the `lnjs`  module which we created in the previous step. 

    cloud-init example:
    #cloud-config
    package_upgrade: true
    packages:
      - nginx
    write_files:
      - owner: www-data:www-data
      - path: /etc/nginx/sites-available/default
        content: |
          server {
            listen 80;
            location / {
              proxy_pass http://${njs_lb_dns}:3000;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection keep-alive;
              proxy_set_header Host $host;
              proxy_cache_bypass $http_upgrade;
            }
          }
    runcmd:
      - service nginx restart​

 

Enabling the secondary region (optional):

For the next apply lets enable the secondary region which will deploy another vnet and create peerings on both ends.  Open `deployment.tfvars` and change `enable_secondary = true`.
Run `./deploy.py -d us2 -a apply

If you get an error, just run the plan again.  Occasionally a resource creation is attempted before its resource group is created.

 

Enable Log Analytics (optional):

You can enable log analytics for your deployment by opening `deployment.tfvars` and change/add `enable_log_analytics = true`.
Run `./deploy.py -d us2 -a apply

Any VM's you have will get a extension added which will auto install the OMS agent and configure it to the log analytics instance.

 

Enable Remote State (optional):

So far your state has been local only which can be found deployments/<deployment code>/state. State should be checked into source control but first should be encrypted as it may contain senstive keys from resources.  The other option is to store the state in a blob storage account by following the below steps.  This can be a bit tricky as we need to play a bit of chicken n egg. 

 

You can enable remote state for your deployment by:

  1. Open `deploy.py` and change REMOTE_STATE_BYPASS = True
  2. Open `deployment.tfvars` and change/add `enable_remote_state = true`
  3. Run and apply `./deploy.py -d us2 -a apply -t remote_state.tf`  to deploy the remote state core resources.
  4. Look at the output for the following command, run it once the above apply is complete.
    Run the following command after the next apply:
    az storage blob upload -f/mnt/c/Projects/terraform-eiac/terraform/azure/deployments/us2/state/main/terraform.tfstate -c main -n terraform.tfstate​
  5. Open `deploy.py` and change REMOTE_STATE_BYPASS = False
  6. Open 'deploy.py' and change UPLOAD_STATE_TO_REMOTE = True to auto upload the local state file to the remote container on next plan
  7. Run a plan `./deploy.py -d us2` which should show the following in the output
    Start remote state engine... Will take a few seconds...
    Uploading State file to Remote State Container...​
  8. Change UPLOAD_STATE_TO_REMOTE = False and run `./deploy.py -d us2`.  View the terminal output and verify that State is still using the remote engine.   Every state modification will not result in a blob snapshot which will allow you to easily rollback.
  9. Once you have verified that remote state is being used you can backup the state folder under the deployment folder and then remove it.

`