Using Terraform in Azure DevOps Pipelines PART 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to templatize a terraform azure devops pipeline [Music] okay so we're going to be using this as an example in a previous video we went over how to create a terraform pipeline in azure devops what i'm going to do is i want to templatize it right so let's go ahead and take a look at this pipeline and basically templatizing will allow us to remove all this hard-coded stuff create a template out of it so that we could use it for other projects other repos within azure devops and to do that we're just going to go ahead and first uh go to the repo section we're going to create a new repo let me call this template and we'll allow it to initialize [Music] we're going to create a new file [Music] we call this terraform validate yaml and i'm going to copy all this so we're going to be creating two yaml files one for the validate stage and one for the deploy stage [Music] okay above this we're going to add a parameter section and we're going to go ahead and add our parameters [Music] and now we're going to replace all these hard-coded values with these parameters okay that looks good i'm gonna go ahead and commit this but before i do let me just copy this section [Music] i'm going to go ahead and put this in a separate branch because i want to test it first [Music] and now i'm going to add a new file this one i'm going to call terraform deploy paste the parameters i'm going to add a new one called deploy environment go back over here [Music] and this is what i want and basically i'll do the same thing just replace all these hardcore values with the parameters here okay i think i have everything now i need to project my work here okay i'm gonna commit that [Music] same branch [Music] okay so now we have two terraform templates and we're going to replace this let's go ahead and erase this the first thing we need to do is declare resources repositories repository it's called templates type is git okay let's create our job section now we're going to specify our template i can go back here to my template and just borrow these parameters specify another template okay so let's now go ahead and grab our hard-coded values so let's go ahead and save this actually save this to my other branch so what i'm going to do is i can't do it from here so i'm just going to copy and paste this let me go into my terraform repo here switch my branch to my templates branch edit this here i'm gonna hit commit and this should trigger the pipeline uh okay i see the problem i didn't mean to create a terraform branch for this they're supposed to be checked into master so i'm just gonna go ahead and merge it to my master branch [Music] okay now we have it in our master branch i apologize for that but let's go ahead and run this pipeline again [Music] oh i guess when i copy it and paste it all the spacing doesn't look correct actually okay i think i've got it this time i'm not a big fan of yamo because of this so let's go ahead and commit this i'm going to commit directly to master i think we should be able to run this let's see line 14. let's try it again okay now it's running this time let's see what we get okay looks like it's done um and it did work so again just to recap uh i wanted to templatize this uh terraform because i want to be able to use it in future videos and i wouldn't want to have to keep doing this over and over again and i hope you learned something from this thank you you
Info
Channel: skunklabz
Views: 11,340
Rating: undefined out of 5
Keywords: SkunkLabz, Episode 17, terraform, templates, azure devops, yaml, yml, pipelines
Id: x631jUw1J04
Channel Id: undefined
Length: 7min 32sec (452 seconds)
Published: Mon Jul 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.