WEBVTT

1
00:00:00.120 --> 00:00:03.000
<v Speaker 1>Welcome to the Deep Dive, the show that's really your

2
00:00:03.160 --> 00:00:06.400
<v Speaker 1>shortcut to being genuinely well informed. We try to pack

3
00:00:06.400 --> 00:00:09.400
<v Speaker 1>it with surprising facts and you know, just enough humor

4
00:00:09.439 --> 00:00:10.199
<v Speaker 1>to keep you hooked.

5
00:00:10.320 --> 00:00:11.199
<v Speaker 2>Yeah. Absolutely.

6
00:00:11.800 --> 00:00:14.439
<v Speaker 1>In today's IT world, it often feels like you're trying

7
00:00:14.439 --> 00:00:17.440
<v Speaker 1>to build a castle while riding a roller coaster. I mean,

8
00:00:17.480 --> 00:00:20.519
<v Speaker 1>things move so fast. Oh definitely, and staying on top

9
00:00:20.559 --> 00:00:23.239
<v Speaker 1>of the tools that truly matter isn't just about keeping up.

10
00:00:23.239 --> 00:00:26.559
<v Speaker 1>It's almost like gaining a superpower. We're talking about a

11
00:00:26.679 --> 00:00:29.559
<v Speaker 1>fundamental shift in how we build and manage our digital

12
00:00:29.640 --> 00:00:32.799
<v Speaker 1>environments infrastructure as code or IAC.

13
00:00:33.119 --> 00:00:36.679
<v Speaker 2>That's right. Imagine defining your entire digital landscape, you know,

14
00:00:36.679 --> 00:00:40.759
<v Speaker 2>from the smallest virtual machine to sprawling global networks, not

15
00:00:40.840 --> 00:00:45.479
<v Speaker 2>through manual clicks and endless configurations, but as elegant, version

16
00:00:45.560 --> 00:00:46.439
<v Speaker 2>controlled code.

17
00:00:46.560 --> 00:00:46.840
<v Speaker 1>Right.

18
00:00:47.079 --> 00:00:51.399
<v Speaker 2>This brings all the power of software development, things like consistency, repeatability,

19
00:00:51.920 --> 00:00:54.920
<v Speaker 2>and automation directly to your infrastructure.

20
00:00:55.079 --> 00:00:58.479
<v Speaker 1>And today you're getting a deep dive into one of

21
00:00:58.479 --> 00:01:03.560
<v Speaker 1>the most powerful tools in that IAC, arsenal Terraform. We've

22
00:01:03.600 --> 00:01:06.560
<v Speaker 1>gone through the brand new Terraform cookbook by Karamsaturli and

23
00:01:06.640 --> 00:01:10.640
<v Speaker 1>Taylor Dolazol just published October twenty twenty four. Treating it

24
00:01:10.719 --> 00:01:14.959
<v Speaker 1>like your personal distilled guide to mastering this incredible tool.

25
00:01:15.519 --> 00:01:19.680
<v Speaker 1>Our mission to arm you with practical, actionable knowledge, cutting

26
00:01:19.680 --> 00:01:22.280
<v Speaker 1>through all the complexity to give you the nuggets you

27
00:01:22.359 --> 00:01:24.319
<v Speaker 1>need to be truly well informed.

28
00:01:24.519 --> 00:01:26.159
<v Speaker 2>And by the end of this deep dive, you'll not

29
00:01:26.200 --> 00:01:29.280
<v Speaker 2>only understand what terraform is, but maybe more importantly, when

30
00:01:29.319 --> 00:01:30.640
<v Speaker 2>and why to actually.

31
00:01:30.400 --> 00:01:31.480
<v Speaker 1>Use it exactly well.

32
00:01:31.480 --> 00:01:33.280
<v Speaker 2>Break down its core building blocks, show you how to

33
00:01:33.280 --> 00:01:36.560
<v Speaker 2>write top tier secure code, and even reveal how it's

34
00:01:36.640 --> 00:01:40.200
<v Speaker 2>driving advanced real world deployments. Get ready for some genuine

35
00:01:40.359 --> 00:01:42.079
<v Speaker 2>aha moments, I think.

36
00:01:41.959 --> 00:01:44.519
<v Speaker 1>Okay, let's unpact this. Then, the book describes Terraform as

37
00:01:44.519 --> 00:01:47.640
<v Speaker 1>an excellent declarative way to manage many things, But what

38
00:01:47.760 --> 00:01:50.799
<v Speaker 1>does that truly mean in practice? Where does terraform really shine?

39
00:01:50.959 --> 00:01:54.879
<v Speaker 2>Well, what's fascinating here is how Terraform becomes like the

40
00:01:54.920 --> 00:01:59.400
<v Speaker 2>conductor for your digital orchestra. It truly excels when you're

41
00:01:59.439 --> 00:02:04.879
<v Speaker 2>managing complex infrastructure made up of many interconnected resources. This

42
00:02:04.959 --> 00:02:09.039
<v Speaker 2>becomes especially invaluable when your operations span multiple cloud providers

43
00:02:09.159 --> 00:02:13.240
<v Speaker 2>think AWS and Azure together, or even integrate with your

44
00:02:13.240 --> 00:02:14.360
<v Speaker 2>on premises.

45
00:02:14.000 --> 00:02:16.080
<v Speaker 1>Environments, right, the hybrid stuff.

46
00:02:15.879 --> 00:02:21.240
<v Speaker 2>Exactly, think about managing multiple environments, dev staging production across

47
00:02:21.280 --> 00:02:25.240
<v Speaker 2>different vendors. Terraform offers a single unified language for all

48
00:02:25.280 --> 00:02:28.199
<v Speaker 2>of that, simplifying what used to be, frankly a nightmare

49
00:02:28.199 --> 00:02:29.719
<v Speaker 2>of different tools and manual steps.

50
00:02:29.919 --> 00:02:33.479
<v Speaker 1>That makes perfect sense for those big distributed, multi vendor systems,

51
00:02:34.159 --> 00:02:38.240
<v Speaker 1>But in my experience, no single tool is a silver bullet.

52
00:02:38.680 --> 00:02:41.759
<v Speaker 1>Are there scenarios where Terraform might be overkill or maybe

53
00:02:41.800 --> 00:02:42.960
<v Speaker 1>even the wrong choice.

54
00:02:43.159 --> 00:02:45.560
<v Speaker 2>Yeah, that's a really important question. You don't always need

55
00:02:45.560 --> 00:02:48.199
<v Speaker 2>a sledgehammer to crack a nut, right. For instance, if

56
00:02:48.240 --> 00:02:51.960
<v Speaker 2>you're only managing a single server, maybe simpler configuration management

57
00:02:52.000 --> 00:02:55.280
<v Speaker 2>tools like ansable or Puppet might be far more straightforward,

58
00:02:55.719 --> 00:02:59.360
<v Speaker 2>easier learning curve too. Similarly, if you're sticking to just

59
00:02:59.439 --> 00:03:03.599
<v Speaker 2>one cloud, say only AWS for a relatively small amount

60
00:03:03.639 --> 00:03:08.639
<v Speaker 2>of infrastructure, they're native tools like AWS Cloud Formation or

61
00:03:08.719 --> 00:03:12.039
<v Speaker 2>Azure Resource Manager if you're on Azure, could absolutely suffice

62
00:03:12.159 --> 00:03:16.280
<v Speaker 2>the integrate really seamlessly. And here's a common one. If

63
00:03:16.319 --> 00:03:20.080
<v Speaker 2>you're heavily using platform as a service or plause solutions

64
00:03:20.080 --> 00:03:23.719
<v Speaker 2>like Netlafi or Google App Engine, the underlying infrastructure is

65
00:03:23.759 --> 00:03:27.680
<v Speaker 2>often managed for you, so Terraform becomes unnecessary for that

66
00:03:27.719 --> 00:03:28.560
<v Speaker 2>specific layer.

67
00:03:28.879 --> 00:03:32.840
<v Speaker 1>Those are crucial distinctions picking the right tool for the job. Now,

68
00:03:32.879 --> 00:03:35.400
<v Speaker 1>before we go too deep into the technical bits, we

69
00:03:35.520 --> 00:03:37.479
<v Speaker 1>kind of have to address something that sparked quite a

70
00:03:37.479 --> 00:03:40.960
<v Speaker 1>bit of discussion in the community recently, Terraform's license change.

71
00:03:41.120 --> 00:03:44.400
<v Speaker 2>Ah. Yes, the license change. In August twenty twenty three,

72
00:03:44.520 --> 00:03:48.719
<v Speaker 2>Hashikorp shifted Terraform's license from the Mozilla Public License the NPL,

73
00:03:49.000 --> 00:03:52.520
<v Speaker 2>to the Business Source License or BSL. This change definitely

74
00:03:52.599 --> 00:03:56.080
<v Speaker 2>led to significant community discussion and importantly the creation of

75
00:03:56.120 --> 00:03:59.080
<v Speaker 2>open tofu. That's an open source fork that remains under

76
00:03:59.120 --> 00:03:59.960
<v Speaker 2>the NPL license.

77
00:04:00.240 --> 00:04:02.840
<v Speaker 1>Okay, so there's an alternative exactly now.

78
00:04:02.879 --> 00:04:06.120
<v Speaker 2>While the Terraform cookbook in therefore are deep dive today

79
00:04:06.639 --> 00:04:09.919
<v Speaker 2>focuses on Hashi Kor's Terraform, it's important to note that

80
00:04:10.000 --> 00:04:13.360
<v Speaker 2>the examples in core concepts were discussing they work pretty

81
00:04:13.400 --> 00:04:16.040
<v Speaker 2>much seamlessly with open tofu as well. Good to know

82
00:04:16.279 --> 00:04:18.240
<v Speaker 2>the main difference you'd see is just the commands you

83
00:04:18.279 --> 00:04:23.480
<v Speaker 2>taught terraform versus tofu. For clarity today, though, we'll stick

84
00:04:23.519 --> 00:04:25.720
<v Speaker 2>to the core Terraform concepts as they're laid out in

85
00:04:25.759 --> 00:04:26.079
<v Speaker 2>the book.

86
00:04:26.279 --> 00:04:30.000
<v Speaker 1>Okay, sounds good. With that important groundwork laid, let's move

87
00:04:30.040 --> 00:04:34.680
<v Speaker 1>into the core building blocks of Terraform. First up providers.

88
00:04:35.160 --> 00:04:38.480
<v Speaker 1>How exactly do these let Terraform connect to and control

89
00:04:38.839 --> 00:04:39.560
<v Speaker 1>the real world?

90
00:04:39.920 --> 00:04:43.040
<v Speaker 2>Right? Providers imagine Terraform needs to talk to aws or

91
00:04:43.079 --> 00:04:46.040
<v Speaker 2>Kubernetes or even GitHub. Doesn't just inherently know how to

92
00:04:46.079 --> 00:04:48.360
<v Speaker 2>do that. Okay, that's where providers come in. They're like

93
00:04:48.360 --> 00:04:53.040
<v Speaker 2>specialized translators, enabling Terraform to speak the specific API language

94
00:04:53.040 --> 00:04:53.720
<v Speaker 2>of each service.

95
00:04:53.800 --> 00:04:54.519
<v Speaker 1>Ah, got it.

96
00:04:54.720 --> 00:04:57.759
<v Speaker 2>This lets you create, read, update, or delete resources in

97
00:04:57.800 --> 00:05:01.879
<v Speaker 2>their environment, but using a consistent Terraform syntax across the board.

98
00:05:02.160 --> 00:05:06.040
<v Speaker 1>So they're the communication layer speaking all those different infrastructure dialects.

99
00:05:06.360 --> 00:05:09.800
<v Speaker 1>And I've heard managing different versions of these providers can

100
00:05:09.839 --> 00:05:13.560
<v Speaker 1>be a bit tricky. You want updates, but you fear

101
00:05:13.639 --> 00:05:16.800
<v Speaker 1>breaking changes. Is there a simple rule of thumb there?

102
00:05:17.240 --> 00:05:19.680
<v Speaker 2>You're absolutely right to bring that up. It's crucial. You

103
00:05:19.759 --> 00:05:24.199
<v Speaker 2>need to specify version constraints for your providers, something like

104
00:05:24.240 --> 00:05:25.040
<v Speaker 2>five point zero.

105
00:05:24.879 --> 00:05:27.079
<v Speaker 1>In your configuration, the tilled greater then.

106
00:05:27.439 --> 00:05:32.240
<v Speaker 2>Exactly the pessimistic version constraint. This prevents unexpected or accidental

107
00:05:32.319 --> 00:05:35.360
<v Speaker 2>upgrades to a new major version that could introduce breaking

108
00:05:35.439 --> 00:05:38.040
<v Speaker 2>changes to your infrastructure. Okay, but it still allows for

109
00:05:38.120 --> 00:05:41.639
<v Speaker 2>bug fixes and minor updates within that major version, keeping

110
00:05:41.639 --> 00:05:44.720
<v Speaker 2>your deployment stable and predictable without fear of a sudden

111
00:05:44.759 --> 00:05:47.079
<v Speaker 2>chaotic change breaking everything makes sense.

112
00:05:47.319 --> 00:05:50.160
<v Speaker 1>Keep things stable that still get fixes. Okay. Next up,

113
00:05:50.199 --> 00:05:52.560
<v Speaker 1>let's talk about Terraform modules. I hear these are all

114
00:05:52.600 --> 00:05:55.279
<v Speaker 1>about reusability, But what exactly are they and how do

115
00:05:55.319 --> 00:05:56.279
<v Speaker 1>they make life easier?

116
00:05:56.360 --> 00:05:59.600
<v Speaker 2>Okay? Modules. If we think of Terraform as a programming

117
00:05:59.639 --> 00:06:03.319
<v Speaker 2>language for infrastructure, then modules are kind of like functions

118
00:06:03.399 --> 00:06:06.560
<v Speaker 2>or subroutines in traditional code. They encapsulate a block of

119
00:06:06.680 --> 00:06:09.720
<v Speaker 2>Terraform code with a specific purpose, and they're designed to

120
00:06:09.759 --> 00:06:13.879
<v Speaker 2>be reusable. The primary benefit modules help you organize your

121
00:06:13.920 --> 00:06:17.240
<v Speaker 2>resources and reuse code, which is vital for consistency and

122
00:06:17.240 --> 00:06:19.720
<v Speaker 2>managing complexity as your infrastructure grows.

123
00:06:19.920 --> 00:06:22.959
<v Speaker 1>Okay, So you can define a standard way to deploy,

124
00:06:23.240 --> 00:06:25.040
<v Speaker 1>say a web server setup.

125
00:06:24.800 --> 00:06:28.040
<v Speaker 2>Exactly, and then you just reuse that module across different

126
00:06:28.040 --> 00:06:31.639
<v Speaker 2>projects or environments instead of copying and pasting code everywhere.

127
00:06:31.720 --> 00:06:34.720
<v Speaker 1>That's a fantastic analogy. So instead of writing the same

128
00:06:34.759 --> 00:06:36.680
<v Speaker 1>block of code over and over, you just create a

129
00:06:36.759 --> 00:06:39.600
<v Speaker 1>module once and I hear there are public modules available

130
00:06:39.680 --> 00:06:40.839
<v Speaker 1>that can save even more time.

131
00:06:40.920 --> 00:06:44.199
<v Speaker 2>Oh definitely. A great example of the book highlights is

132
00:06:44.279 --> 00:06:48.800
<v Speaker 2>using the public AWS EKS module that's available on the Terraform.

133
00:06:48.439 --> 00:06:51.680
<v Speaker 1>Registry EKS the Kubernetes service on AWS.

134
00:06:51.920 --> 00:06:54.879
<v Speaker 2>Right, with just a few lines of code calling that module,

135
00:06:55.160 --> 00:06:58.800
<v Speaker 2>you can provision a fully configured Kubernetes cluster. This not

136
00:06:58.839 --> 00:07:01.519
<v Speaker 2>only saves you immense time, but also ensures that you're

137
00:07:01.560 --> 00:07:06.120
<v Speaker 2>automatically applying best practices and configurations that have been battle

138
00:07:06.160 --> 00:07:09.800
<v Speaker 2>tested by the community. And when you create your own module,

139
00:07:10.040 --> 00:07:13.079
<v Speaker 2>it typically includes a main dot TF file for the

140
00:07:13.120 --> 00:07:16.720
<v Speaker 2>actual resources variables, dot TF for flexible inputs so people

141
00:07:16.759 --> 00:07:21.360
<v Speaker 2>can customize it outputs, dot TF for values the module returns,

142
00:07:21.800 --> 00:07:26.959
<v Speaker 2>and crucially, a reme dot MD for documentation. Got to

143
00:07:27.000 --> 00:07:30.680
<v Speaker 2>have that documentation, absolutely, That documentation is key so others

144
00:07:30.720 --> 00:07:32.720
<v Speaker 2>know how to use it. Okay, that sounds like a

145
00:07:32.720 --> 00:07:37.199
<v Speaker 2>lifesaver for boostrapping complex infrastructure. Speaking of what Terraform knows

146
00:07:37.240 --> 00:07:39.839
<v Speaker 2>about your infrastructure, let's talk about the state file. What

147
00:07:40.040 --> 00:07:42.720
<v Speaker 2>is it and why is remote state such a big

148
00:07:42.759 --> 00:07:44.319
<v Speaker 2>deal especially for teams.

149
00:07:44.639 --> 00:07:47.800
<v Speaker 1>Right, the state file, it's essentially terraforms memory it's the

150
00:07:47.879 --> 00:07:50.879
<v Speaker 1>master record of every piece of infrastructure it's responsible for

151
00:07:50.959 --> 00:07:53.959
<v Speaker 1>in the real world. Okay, it tracks the exact attributes

152
00:07:53.959 --> 00:07:58.160
<v Speaker 1>and relationships of all your deployed resources. Now, for team environments,

153
00:07:58.240 --> 00:08:01.279
<v Speaker 1>storing this state remotely, not on laptop is a critical

154
00:08:01.319 --> 00:08:02.160
<v Speaker 1>best practice.

155
00:08:02.240 --> 00:08:02.759
<v Speaker 2>Why is that?

156
00:08:03.360 --> 00:08:06.199
<v Speaker 1>Well, First, it ensures the state is centralized and accessible

157
00:08:06.199 --> 00:08:09.439
<v Speaker 1>from anywhere. This prevents conflicts when multiple team members are

158
00:08:09.480 --> 00:08:12.040
<v Speaker 1>working on the same infrastructure. You don't want two people

159
00:08:12.120 --> 00:08:15.920
<v Speaker 1>applying changes based on different versions of the state. Ah yeah,

160
00:08:16.000 --> 00:08:17.160
<v Speaker 1>that sounds bad. It is.

161
00:08:17.480 --> 00:08:20.360
<v Speaker 2>And what's maybe even more important is the security aspect.

162
00:08:20.759 --> 00:08:25.360
<v Speaker 2>Remote state provides additional security by keeping potentially sensitive information

163
00:08:25.439 --> 00:08:28.680
<v Speaker 2>out of your version control systems like GET where it

164
00:08:28.759 --> 00:08:31.160
<v Speaker 2>might otherwise inadvertently end up in plain text.

165
00:08:31.480 --> 00:08:34.200
<v Speaker 1>So it's not just about collaboration, but a vital security

166
00:08:34.200 --> 00:08:37.120
<v Speaker 1>measure too. Okay, what are some of the popular options

167
00:08:37.120 --> 00:08:39.240
<v Speaker 1>for these remote back ends? Then? Where do you store

168
00:08:39.279 --> 00:08:39.720
<v Speaker 1>this state?

169
00:08:40.240 --> 00:08:43.440
<v Speaker 2>Popular remote back ends include Hashi Coore's own managed service

170
00:08:43.600 --> 00:08:48.159
<v Speaker 2>HGP Terraform. There are also robust cloud storage solutions like

171
00:08:48.200 --> 00:08:53.240
<v Speaker 2>Amazon S three for AWS, Google Cloud Storage, Azure blob storage,

172
00:08:53.480 --> 00:08:55.679
<v Speaker 2>or even a self hosted option like the console key

173
00:08:55.720 --> 00:08:58.639
<v Speaker 2>Value store lots of choices. Yeah, plenty of options depending

174
00:08:58.679 --> 00:09:00.960
<v Speaker 2>on your setup. And for those those moments when you

175
00:09:01.039 --> 00:09:04.039
<v Speaker 2>need to quickly peek into or debug your state without

176
00:09:04.039 --> 00:09:07.279
<v Speaker 2>applying changes, the terraform console command is incredibly powerful.

177
00:09:07.679 --> 00:09:08.200
<v Speaker 1>What does that do?

178
00:09:08.600 --> 00:09:11.240
<v Speaker 2>It lets you introspect your terraform state in real time.

179
00:09:11.639 --> 00:09:14.919
<v Speaker 2>You can type in expressions, look at resource attributes, all

180
00:09:14.960 --> 00:09:19.159
<v Speaker 2>without modifying your actual configuration files. It's perfect for rapid

181
00:09:19.200 --> 00:09:22.279
<v Speaker 2>experimentation and just understanding the current values of things.

182
00:09:22.360 --> 00:09:26.120
<v Speaker 1>That's a true aha moment right there. Interactive state inspection

183
00:09:26.200 --> 00:09:29.919
<v Speaker 1>without touching your config Okay, Now let's move into crafting

184
00:09:30.000 --> 00:09:33.960
<v Speaker 1>quality and secure code. What are the first fundamental steps

185
00:09:34.039 --> 00:09:37.720
<v Speaker 1>for basic code hygiene? What should everyone be doing right?

186
00:09:37.879 --> 00:09:42.000
<v Speaker 2>Every good code base infrastructure code included begins with cleanliness

187
00:09:42.000 --> 00:09:47.279
<v Speaker 2>and correctness. First up is Terraform FMT. It's your automatic formatting.

188
00:09:46.840 --> 00:09:49.080
<v Speaker 1>Tool FMT for format exactly.

189
00:09:49.279 --> 00:09:52.440
<v Speaker 2>It automatically formats your code to the recommended style guidelines.

190
00:09:52.480 --> 00:09:54.559
<v Speaker 2>Makes it easier to read and maintain for everyone on

191
00:09:54.600 --> 00:09:56.679
<v Speaker 2>your team. Consistent style helps a lot.

192
00:09:56.840 --> 00:09:58.080
<v Speaker 1>Okay, so that's readability.

193
00:09:58.600 --> 00:10:02.000
<v Speaker 2>Then there's terraform validate. This checks for syntax and semantics.

194
00:10:02.200 --> 00:10:06.320
<v Speaker 2>It catches things like syntax errors, missing required arguments for resource,

195
00:10:06.679 --> 00:10:10.879
<v Speaker 2>incorrect references between resources. The basic structural.

196
00:10:10.399 --> 00:10:11.559
<v Speaker 1>Stuff seems essential.

197
00:10:11.679 --> 00:10:15.320
<v Speaker 2>It is, but here's a crucial point. You must run

198
00:10:15.399 --> 00:10:19.279
<v Speaker 2>terraform in it first. Why is that because validation requires

199
00:10:19.360 --> 00:10:22.639
<v Speaker 2>terraform to download and understand the providers you're using. It

200
00:10:22.679 --> 00:10:25.840
<v Speaker 2>needs that provider context to know what arguments are valid for,

201
00:10:25.919 --> 00:10:29.519
<v Speaker 2>say an AWRS instance. Without in it, it can't truly

202
00:10:29.600 --> 00:10:30.919
<v Speaker 2>validate your code properly.

203
00:10:30.960 --> 00:10:35.200
<v Speaker 1>Got it in it first, then validate. So FMT is

204
00:10:35.240 --> 00:10:39.840
<v Speaker 1>about readability, validate is about basic correctness, But what about

205
00:10:40.039 --> 00:10:43.759
<v Speaker 1>deeper issues like potential security flaws or maybe just not

206
00:10:43.919 --> 00:10:47.480
<v Speaker 1>following best practices. That sounds like where linters and security

207
00:10:47.519 --> 00:10:48.200
<v Speaker 1>scanners come in.

208
00:10:48.320 --> 00:10:51.480
<v Speaker 2>Absolutely, you've got the basics covered with FMT and validate,

209
00:10:51.759 --> 00:10:54.159
<v Speaker 2>but you need to go further. Tools like t flint,

210
00:10:54.200 --> 00:10:57.120
<v Speaker 2>which is a popular third party linting tool, catch issues

211
00:10:57.200 --> 00:11:01.320
<v Speaker 2>terraform validate might miss entirely, like what like unused variables

212
00:11:01.360 --> 00:11:05.519
<v Speaker 2>cluttering your code, duplicate resource definitions, maybe incorrect resource properties

213
00:11:05.559 --> 00:11:09.679
<v Speaker 2>that aren't technically syntax errors but are just wrong. And importantly,

214
00:11:09.799 --> 00:11:13.519
<v Speaker 2>it can even flag potential security risks like overly permissive

215
00:11:13.559 --> 00:11:14.799
<v Speaker 2>security group rules.

216
00:11:14.919 --> 00:11:16.399
<v Speaker 1>Okay, so it's smarter than validate.

217
00:11:16.639 --> 00:11:19.720
<v Speaker 2>Yeah, it has more checks, more opinions based on common practices.

218
00:11:20.279 --> 00:11:24.480
<v Speaker 2>Then there's TSSEC, another excellent third party security scanner. This

219
00:11:24.519 --> 00:11:29.399
<v Speaker 2>one specifically focuses on identifying insecure patterns, misconfigurations, and non

220
00:11:29.440 --> 00:11:33.440
<v Speaker 2>compliant settings in your terraform code. Mean example, Sure, it

221
00:11:33.480 --> 00:11:36.480
<v Speaker 2>can warn you about things like unencrypted s three buckets

222
00:11:36.840 --> 00:11:39.679
<v Speaker 2>or security groups with ingress rules that are way too

223
00:11:39.720 --> 00:11:43.080
<v Speaker 2>broad like allowing access from anywhere on the Internet. You

224
00:11:43.080 --> 00:11:46.200
<v Speaker 2>can even tell tfsec to ignore specific checks if you

225
00:11:46.279 --> 00:11:49.840
<v Speaker 2>have a documented, justified reason using an inline comment like

226
00:11:50.080 --> 00:11:51.799
<v Speaker 2>hashtag tfsec dot ignore.

227
00:11:51.720 --> 00:11:54.360
<v Speaker 1>Ah, so you can overwrite it if needed. That's handy.

228
00:11:54.840 --> 00:11:58.080
<v Speaker 1>So these tools act like extra sets of vigilant eyes,

229
00:11:58.320 --> 00:12:01.120
<v Speaker 1>scrutinizing your code before you even think about deploying. How

230
00:12:01.159 --> 00:12:03.919
<v Speaker 1>do we move from just checking code to actually enforcing

231
00:12:03.960 --> 00:12:07.440
<v Speaker 1>policies and compliance across our infrastructure deployments like preventing bad

232
00:12:07.480 --> 00:12:08.240
<v Speaker 1>things from happening?

233
00:12:08.320 --> 00:12:11.440
<v Speaker 2>Right enforcement. This is where policy is code really shines,

234
00:12:11.600 --> 00:12:14.919
<v Speaker 2>often leveraging tools like Open Policy Agent or OPA. Yeah,

235
00:12:15.000 --> 00:12:18.240
<v Speaker 2>open Policy Agent, it's a general purpose policy engine within

236
00:12:18.320 --> 00:12:22.080
<v Speaker 2>terraform itself. You can define preconditions using validation blocks inside

237
00:12:22.080 --> 00:12:25.840
<v Speaker 2>your variable definitions. This ensures that specific conditions are met

238
00:12:25.840 --> 00:12:27.840
<v Speaker 2>before terraform even attempts to apply.

239
00:12:27.679 --> 00:12:29.159
<v Speaker 1>Changes, like what kind of condition.

240
00:12:29.720 --> 00:12:32.919
<v Speaker 2>For example, you could enforce that an instance type variable

241
00:12:33.000 --> 00:12:35.799
<v Speaker 2>must be either T two dot micro or T two

242
00:12:35.840 --> 00:12:39.600
<v Speaker 2>dot small and nothing else. Terraform checks this before planning

243
00:12:40.159 --> 00:12:43.080
<v Speaker 2>post conditions. On the other hand, verify the state after

244
00:12:43.120 --> 00:12:45.039
<v Speaker 2>a resource is created or updated.

245
00:12:45.120 --> 00:12:46.399
<v Speaker 1>Okay, and opa.

246
00:12:46.399 --> 00:12:49.080
<v Speaker 2>OPA takes it a step further. It lets you write

247
00:12:49.200 --> 00:12:52.519
<v Speaker 2>much more complex policies as code. You could restrict allowed

248
00:12:52.519 --> 00:12:56.039
<v Speaker 2>EC two instance types across your whole organization, or enforce

249
00:12:56.120 --> 00:12:59.120
<v Speaker 2>that all EACY two instances must have a specific name

250
00:12:59.200 --> 00:13:02.720
<v Speaker 2>tag powerful. And what's truly powerful is that OPIA can

251
00:13:02.720 --> 00:13:06.120
<v Speaker 2>be integrated directly into your CICD pipelines. This means it

252
00:13:06.120 --> 00:13:09.120
<v Speaker 2>can check your terraform plan and prevent non compliant changes

253
00:13:09.159 --> 00:13:11.679
<v Speaker 2>from ever being applied to your production environment automatically.

254
00:13:11.960 --> 00:13:16.200
<v Speaker 1>That's incredibly powerful, preventing bad configurations from ever reaching production

255
00:13:16.720 --> 00:13:20.240
<v Speaker 1>like a gatekeeper. And what about keeping our documentation up

256
00:13:20.240 --> 00:13:23.399
<v Speaker 1>to date or our provider versions. That sounds like a

257
00:13:23.440 --> 00:13:26.360
<v Speaker 1>lot of manual, painstaking work without automation.

258
00:13:26.600 --> 00:13:29.600
<v Speaker 2>It used to be, but not anymore. There are great tools.

259
00:13:29.639 --> 00:13:34.360
<v Speaker 2>Now for docs, there's Terraform Docs. It automatically generates documentation

260
00:13:34.440 --> 00:13:40.240
<v Speaker 2>for your modules, detailing inputs, outputs, providers, resources, everything automatically. Yep.

261
00:13:40.519 --> 00:13:43.159
<v Speaker 2>You can integrate this into get pre commit hooks or

262
00:13:43.200 --> 00:13:47.000
<v Speaker 2>your CICD pipeline to ensure your documentation is always fresh

263
00:13:47.039 --> 00:13:49.960
<v Speaker 2>and reflects the actual code. No more stale.

264
00:13:49.720 --> 00:13:52.960
<v Speaker 1>Read mase nice and providers for.

265
00:13:52.960 --> 00:13:56.360
<v Speaker 2>Keeping your provider versions current githubs. De pendabot is fantastic

266
00:13:56.679 --> 00:14:00.200
<v Speaker 2>could automatically create poll requests to update your Terraform provider version,

267
00:14:00.639 --> 00:14:03.559
<v Speaker 2>ensuring you leverage the latest available features and bug fixes,

268
00:14:03.919 --> 00:14:06.200
<v Speaker 2>all within the version constraints you specified earlier.

269
00:14:06.360 --> 00:14:08.679
<v Speaker 1>Ah, so it respects the five point zero kind of

270
00:14:08.679 --> 00:14:09.480
<v Speaker 1>thing exactly.

271
00:14:09.600 --> 00:14:12.240
<v Speaker 2>It automates the mundane but important task of staying up

272
00:14:12.279 --> 00:14:15.000
<v Speaker 2>to date safely. It's all about automating these chores so

273
00:14:15.039 --> 00:14:17.840
<v Speaker 2>your team can focus on the truly critical and innovative work.

274
00:14:18.120 --> 00:14:22.159
<v Speaker 1>That's brilliant. And speaking of consistency and automation, how can

275
00:14:22.200 --> 00:14:25.559
<v Speaker 1>teams ensure everyone is working with the exact same development

276
00:14:25.639 --> 00:14:28.360
<v Speaker 1>setup you know to solve that dreaded well, it works

277
00:14:28.360 --> 00:14:30.399
<v Speaker 1>on my machine problem exactly.

278
00:14:31.080 --> 00:14:35.360
<v Speaker 2>That phrase is the bane of many developers' existence. This

279
00:14:35.440 --> 00:14:38.360
<v Speaker 2>is where tools like getub code spaces and dev containers

280
00:14:38.440 --> 00:14:41.240
<v Speaker 2>are absolute game changers. How do they help They provide

281
00:14:41.240 --> 00:14:45.679
<v Speaker 2>a consistent, pre configured development environment defining code. This ensures

282
00:14:45.720 --> 00:14:48.559
<v Speaker 2>all contributors have the exact same tool set, the same

283
00:14:48.679 --> 00:14:53.240
<v Speaker 2>Terraform version, same lenters, the same helper scripts, everything, regardless

284
00:14:53.240 --> 00:14:57.360
<v Speaker 2>of their local machine setup, whether they're on Mac, Windows, Linux.

285
00:14:56.960 --> 00:14:59.279
<v Speaker 1>So everyone's using the same environment precisely.

286
00:15:00.000 --> 00:15:03.639
<v Speaker 2>This significantly reduces those frustrating it works on my machine issues.

287
00:15:03.919 --> 00:15:07.279
<v Speaker 2>By standardizing the development environment across your entire team, it's

288
00:15:07.360 --> 00:15:10.000
<v Speaker 2>like everyone getting the same perfectly pre tuned race car

289
00:15:10.080 --> 00:15:13.200
<v Speaker 2>before they even hit the track. Makes collaboration much smoother.

290
00:15:13.480 --> 00:15:16.480
<v Speaker 1>Okay, we've covered the why, the when, the core blocks,

291
00:15:16.519 --> 00:15:20.240
<v Speaker 1>and keeping code clean. Now let's dive deeper and master

292
00:15:20.399 --> 00:15:25.840
<v Speaker 1>terraforms language itself, starting with something practical. Cleaning up messy

293
00:15:26.000 --> 00:15:29.600
<v Speaker 1>user inputs. You know, those annoying extra spaces or maybe

294
00:15:29.679 --> 00:15:32.919
<v Speaker 1>unwanted prefixes that can throw off an entire deployment if

295
00:15:32.960 --> 00:15:33.679
<v Speaker 1>you're not careful.

296
00:15:33.799 --> 00:15:36.120
<v Speaker 2>Yeah, this is really common practical challenge you hit pretty

297
00:15:36.200 --> 00:15:40.279
<v Speaker 2>quickly in real world configurations. Terraform offers functions for this

298
00:15:40.759 --> 00:15:43.799
<v Speaker 2>there's trim space, which neatly removes leading and trailing spaces

299
00:15:43.799 --> 00:15:45.399
<v Speaker 2>and new lines from a strength.

300
00:15:45.799 --> 00:15:49.759
<v Speaker 1>Very handy, okay, simple enough? What about prefixes or suffixes?

301
00:15:50.000 --> 00:15:53.279
<v Speaker 2>For removing specific prefixes and suffixes, you can achieve this

302
00:15:53.399 --> 00:15:56.720
<v Speaker 2>by intelligently using the replaced function. You basically tell it

303
00:15:56.720 --> 00:15:58.840
<v Speaker 2>to replace the unwanted part of the string with an

304
00:15:58.879 --> 00:16:02.840
<v Speaker 2>empty string. It allows for much cleaner and more predictable data,

305
00:16:03.000 --> 00:16:04.759
<v Speaker 2>preventing subtle errors downstream.

306
00:16:05.279 --> 00:16:08.759
<v Speaker 1>That's super useful. Little cleanup functions save a lot of headaches,

307
00:16:08.799 --> 00:16:11.879
<v Speaker 1>and sometimes you need more sophistic kid. String manipulation like

308
00:16:11.960 --> 00:16:15.759
<v Speaker 1>pattern matching, does Terraform handle regular expressions rajex?

309
00:16:15.879 --> 00:16:19.840
<v Speaker 2>It absolutely does. Terraform supports functions like rejex rejects all,

310
00:16:20.200 --> 00:16:22.519
<v Speaker 2>and you can use rejects within the replace function two

311
00:16:22.840 --> 00:16:25.519
<v Speaker 2>for powerful pattern matching and string manipulation.

312
00:16:26.039 --> 00:16:28.399
<v Speaker 1>Can you give an example, sure, think of a vivid one.

313
00:16:29.200 --> 00:16:32.080
<v Speaker 2>You could use a regular expression with replace to mass

314
00:16:32.159 --> 00:16:35.840
<v Speaker 2>sensitive data like a social security number, preserving only the

315
00:16:35.919 --> 00:16:39.600
<v Speaker 2>last four digits while replacing the rest with excess. That's

316
00:16:39.639 --> 00:16:42.840
<v Speaker 2>a common security and data handling requirement you can implement

317
00:16:43.000 --> 00:16:44.080
<v Speaker 2>right in Terraform.

318
00:16:44.159 --> 00:16:47.679
<v Speaker 1>Very cool, okay, and what about just standardizing string inputs,

319
00:16:47.679 --> 00:16:50.840
<v Speaker 1>like for naming conventions, maybe you need everything lowercase or

320
00:16:51.000 --> 00:16:52.399
<v Speaker 1>maybe title case for tags.

321
00:16:52.679 --> 00:16:56.399
<v Speaker 2>Terraform has you covered there too. Simple functions title upper

322
00:16:56.480 --> 00:16:59.799
<v Speaker 2>and lower They help standardized string inputs, which is particularly

323
00:17:00.159 --> 00:17:04.079
<v Speaker 2>ful for maintaining consistent naming conventions across your resources, or

324
00:17:04.119 --> 00:17:07.000
<v Speaker 2>when you're integrating with external systems that might have case

325
00:17:07.039 --> 00:17:10.759
<v Speaker 2>sensitive requirements. Easy enough it is. It's important to note, though,

326
00:17:10.759 --> 00:17:14.119
<v Speaker 2>that their primary focus is on English text, so complex

327
00:17:14.240 --> 00:17:17.480
<v Speaker 2>unicode casing might behave differently good caveat.

328
00:17:17.799 --> 00:17:20.440
<v Speaker 1>Okay, so we're talking about making our code more robust.

329
00:17:21.119 --> 00:17:25.759
<v Speaker 1>What about handling potential errors gracefully when data might be

330
00:17:25.799 --> 00:17:29.880
<v Speaker 1>missing or maybe in an unexpected format That happens surprisingly

331
00:17:29.920 --> 00:17:31.200
<v Speaker 1>often in complex systems.

332
00:17:31.279 --> 00:17:33.640
<v Speaker 2>Right, oh all the time. This is where they can

333
00:17:33.680 --> 00:17:37.039
<v Speaker 2>and try functions become incredibly valuable. They allow you to

334
00:17:37.039 --> 00:17:40.519
<v Speaker 2>handle potential errors gracefully during terraforms processing. How do they

335
00:17:40.559 --> 00:17:42.640
<v Speaker 2>work well? For I? Lets you attempt a series of

336
00:17:42.680 --> 00:17:45.000
<v Speaker 2>expressions and returns the results of the first one that

337
00:17:45.079 --> 00:17:47.920
<v Speaker 2>doesn't err. You can provide a final default value if

338
00:17:47.920 --> 00:17:52.319
<v Speaker 2>all attempts fail. Can simply checks if an expression would

339
00:17:52.319 --> 00:17:55.000
<v Speaker 2>succeed without actually returning its value just gives you a

340
00:17:55.039 --> 00:17:57.400
<v Speaker 2>tru or false AH, so you can use these to

341
00:17:57.440 --> 00:18:00.480
<v Speaker 2>provide default values when necessary, or to check if an

342
00:18:00.480 --> 00:18:04.079
<v Speaker 2>optional attribute exists before trying to access it. This leads

343
00:18:04.079 --> 00:18:07.559
<v Speaker 2>to much more robust and resilient configurations that won't just

344
00:18:07.640 --> 00:18:10.440
<v Speaker 2>crash and burn if a piece of data isn't exactly

345
00:18:10.440 --> 00:18:13.359
<v Speaker 2>where you expected to be, make sure deployment's far more reliable.

346
00:18:13.559 --> 00:18:17.079
<v Speaker 1>That's a definite game changer for building reliable infrastructure in

347
00:18:17.119 --> 00:18:22.000
<v Speaker 1>the real world. Okay, shifting gears to networks, especially in

348
00:18:22.119 --> 00:18:26.599
<v Speaker 1>vast cloud environments, precise calculations for dividing up IP address

349
00:18:26.640 --> 00:18:31.680
<v Speaker 1>blocks CIDR blocks into smaller subnets are absolutely essential and

350
00:18:31.799 --> 00:18:36.000
<v Speaker 1>kind of fiddly to do manually. Does Terrorform simplify that complexity.

351
00:18:36.079 --> 00:18:39.680
<v Speaker 2>It does beautifully with the sid subnet function. This function

352
00:18:39.799 --> 00:18:44.160
<v Speaker 2>allows for precise, repeatable calculations to divide a large CIDR

353
00:18:44.200 --> 00:18:45.720
<v Speaker 2>block into smaller.

354
00:18:45.400 --> 00:18:48.440
<v Speaker 1>Subnets, like taking a big block and slicing.

355
00:18:48.000 --> 00:18:51.720
<v Speaker 2>It exactly, for instance, breaking a sixteen network address block

356
00:18:51.960 --> 00:18:55.799
<v Speaker 2>into multiple twenty four subnets for different purposes. It automates

357
00:18:55.799 --> 00:18:59.759
<v Speaker 2>in scales network design, eliminating manual calculation errors and ensuring

358
00:18:59.759 --> 00:19:02.720
<v Speaker 2>a fit ip address utilization. It's like having a perfectly

359
00:19:02.759 --> 00:19:04.920
<v Speaker 2>precise digital slicer for your network.

360
00:19:04.960 --> 00:19:07.759
<v Speaker 1>Cake nice analogy, so it's like slicing a big network

361
00:19:07.799 --> 00:19:11.960
<v Speaker 1>into perfect smaller pieces. Very neat. What about conditional logic?

362
00:19:12.279 --> 00:19:15.119
<v Speaker 1>Creating resources only when certain conditions are met, or maybe

363
00:19:15.160 --> 00:19:17.200
<v Speaker 1>processing a list of data in a specific order.

364
00:19:17.319 --> 00:19:20.759
<v Speaker 2>Terraform handles conditional logic primarily using the count meta argument.

365
00:19:20.839 --> 00:19:22.599
<v Speaker 2>It's a bit of a classic terraform pattern.

366
00:19:22.680 --> 00:19:24.279
<v Speaker 1>How does count work for conditions?

367
00:19:24.920 --> 00:19:28.440
<v Speaker 2>You set count based on a boolean expression, for example,

368
00:19:28.640 --> 00:19:32.039
<v Speaker 2>count var dot create and instance spitting one bin and zero.

369
00:19:32.480 --> 00:19:35.279
<v Speaker 2>This means terraform will create one instance of the resource

370
00:19:35.519 --> 00:19:38.480
<v Speaker 2>if the variablevar dot create an instance is true, and

371
00:19:38.680 --> 00:19:42.119
<v Speaker 2>zero instances if it's false, effectively turning the resource on

372
00:19:42.319 --> 00:19:42.680
<v Speaker 2>or off.

373
00:19:42.880 --> 00:19:45.440
<v Speaker 1>Simple on off switch. What about processing lists?

374
00:19:45.920 --> 00:19:49.880
<v Speaker 2>For sequential processing, especially when iterating over lists or maps,

375
00:19:50.200 --> 00:19:53.519
<v Speaker 2>you often use count in conjunction with its index. Count

376
00:19:53.519 --> 00:19:56.880
<v Speaker 2>dot index gives you the current iteration number zero, one, two.

377
00:19:57.480 --> 00:20:01.119
<v Speaker 2>This is incredibly useful for resources that have index based dependencies,

378
00:20:01.480 --> 00:20:04.480
<v Speaker 2>like creating a series of numbered subnets, or maybe assigning

379
00:20:04.519 --> 00:20:07.359
<v Speaker 2>im roles sequentially for a set of applications based on

380
00:20:07.400 --> 00:20:07.759
<v Speaker 2>a list.

381
00:20:07.799 --> 00:20:10.359
<v Speaker 1>Okay, so count is quite versatile. That's a deep dive

382
00:20:10.400 --> 00:20:14.319
<v Speaker 1>into the language itself. What about dynamically generating configuration files

383
00:20:14.319 --> 00:20:17.480
<v Speaker 1>on the fly, or even consuming external data like from

384
00:20:17.519 --> 00:20:20.480
<v Speaker 1>an API and using that to influence your infrastructure.

385
00:20:19.920 --> 00:20:24.359
<v Speaker 2>Build This is where Terraform gets truly flexible and powerful.

386
00:20:24.400 --> 00:20:27.240
<v Speaker 2>Connecting to the outside world. You can use the template

387
00:20:27.319 --> 00:20:29.920
<v Speaker 2>file data source. Well that's the older way. Now it's

388
00:20:30.000 --> 00:20:32.759
<v Speaker 2>usually the template file function to generate configuration files or

389
00:20:32.759 --> 00:20:35.799
<v Speaker 2>scripts dynamically based on input variables.

390
00:20:35.519 --> 00:20:37.000
<v Speaker 1>Like generating a custom.

391
00:20:36.680 --> 00:20:39.960
<v Speaker 2>Script exactly like producing a customized Bash script or a

392
00:20:40.000 --> 00:20:43.319
<v Speaker 2>configuration file for an application on the fly, injecting values

393
00:20:43.359 --> 00:20:45.839
<v Speaker 2>from your Terraform variables right into the template.

394
00:20:45.559 --> 00:20:47.039
<v Speaker 1>Cool and external data.

395
00:20:47.119 --> 00:20:50.559
<v Speaker 2>For integrating external data, the HTTP data source is really useful.

396
00:20:50.599 --> 00:20:53.319
<v Speaker 2>It allows you to fetch data from an external API

397
00:20:53.799 --> 00:20:58.039
<v Speaker 2>endpoint maybe ipminfo dot io to get your build agent's public.

398
00:20:57.799 --> 00:20:59.960
<v Speaker 1>IP address, for example, and then use that data.

399
00:21:00.160 --> 00:21:03.480
<v Speaker 2>Yep. You can then use that fetched information directly within

400
00:21:03.519 --> 00:21:08.200
<v Speaker 2>your Terraform configuration, perhaps to configure a security group rule dynamically.

401
00:21:08.680 --> 00:21:12.440
<v Speaker 2>This enables dynamic integration of external data, making your infrastructure

402
00:21:12.559 --> 00:21:14.839
<v Speaker 2>even more adaptable and context to wear.

403
00:21:14.920 --> 00:21:18.039
<v Speaker 1>Wow. So you can pull in real time information and

404
00:21:18.160 --> 00:21:21.160
<v Speaker 1>use it to build your infrastructure. It's a huge leap

405
00:21:21.200 --> 00:21:24.279
<v Speaker 1>in dynamism adapting to the world around it. Okay, now

406
00:21:24.319 --> 00:21:27.480
<v Speaker 1>let's look at some more advanced strategies and real world impact.

407
00:21:28.039 --> 00:21:32.799
<v Speaker 1>Let's start with upgrading terraform itself. Is that a complicated process,

408
00:21:32.880 --> 00:21:36.759
<v Speaker 1>especially if you're on older versions, seems potentially risky.

409
00:21:37.319 --> 00:21:40.839
<v Speaker 2>Upgrading Terraform, especially if you're coming from significantly older versions

410
00:21:40.880 --> 00:21:43.680
<v Speaker 2>like pre one point zero, is definitely a measured process.

411
00:21:43.880 --> 00:21:47.240
<v Speaker 2>It often requires step by step updates through intermediate versions.

412
00:21:47.279 --> 00:21:49.440
<v Speaker 2>You can't always just jump straight to the latest.

413
00:21:49.119 --> 00:21:50.039
<v Speaker 1>Okay, methodical.

414
00:21:50.319 --> 00:21:52.960
<v Speaker 2>However, here's where it gets really interesting and actually less

415
00:21:53.000 --> 00:21:57.160
<v Speaker 2>daunting that you used to be. Hashikorp introduced compatibility guarantees

416
00:21:57.319 --> 00:22:00.559
<v Speaker 2>for the entire Terraform V one dot x line life cycle.

417
00:22:00.640 --> 00:22:01.319
<v Speaker 1>What does that mean.

418
00:22:01.759 --> 00:22:05.200
<v Speaker 2>It means they've committed to not introducing breaking changes to

419
00:22:05.240 --> 00:22:09.039
<v Speaker 2>the core terraform language or state handling within any one

420
00:22:09.119 --> 00:22:12.519
<v Speaker 2>point x release. Providers might still have breaking changes, but

421
00:22:12.599 --> 00:22:14.640
<v Speaker 2>the core Terraform engine should be stable.

422
00:22:14.799 --> 00:22:16.640
<v Speaker 1>Ah, that's reassuring, it is.

423
00:22:16.920 --> 00:22:19.480
<v Speaker 2>The general recommendation is to try and stay no more

424
00:22:19.519 --> 00:22:23.599
<v Speaker 2>than say two minor versions behind the latest release that

425
00:22:23.640 --> 00:22:26.599
<v Speaker 2>translates to roughly a nine to twelve month lag. This

426
00:22:26.759 --> 00:22:29.720
<v Speaker 2>shows you benefit from bug fixes, security enhancements, and new

427
00:22:29.759 --> 00:22:33.960
<v Speaker 2>features without the constant fear of a sudden, chaotic breaking

428
00:22:34.079 --> 00:22:35.759
<v Speaker 2>change in the core tooling itself.

429
00:22:35.920 --> 00:22:39.640
<v Speaker 1>That's great news for stability and makes planning upgrades easier. Now,

430
00:22:39.680 --> 00:22:43.079
<v Speaker 1>for those really large scale, complex environments, how does terraform

431
00:22:43.119 --> 00:22:47.279
<v Speaker 1>truly help with scalability and maybe multi cloud strategies? It

432
00:22:47.319 --> 00:22:50.680
<v Speaker 1>sounds like configurations could easily become unweelly monsters.

433
00:22:50.799 --> 00:22:54.039
<v Speaker 2>A core tenet, as we touched on earlier, is modular design.

434
00:22:54.920 --> 00:22:59.160
<v Speaker 2>Creating modular Terraform configurations is absolutely key for improved organization,

435
00:22:59.519 --> 00:23:03.519
<v Speaker 2>reuse ability, and maintainability at scale. Breaking it down exactly,

436
00:23:03.799 --> 00:23:08.160
<v Speaker 2>you break down immense infrastructures into smaller, focused, manageable components modules.

437
00:23:08.279 --> 00:23:11.559
<v Speaker 2>This makes it much easier to understand, test, and manage independently.

438
00:23:11.640 --> 00:23:12.839
<v Speaker 1>Okay, And for dynamism.

439
00:23:12.960 --> 00:23:16.599
<v Speaker 2>For true large scale dynamic infrastructures, you lean heavily on

440
00:23:16.640 --> 00:23:20.240
<v Speaker 2>the fortune meta argument and for expressions. These allow you

441
00:23:20.279 --> 00:23:23.519
<v Speaker 2>to dynamically generate resources based on maps or sets of strings,

442
00:23:23.920 --> 00:23:28.039
<v Speaker 2>deploying across multiple environments, regions, or accounts. With very little

443
00:23:28.079 --> 00:23:32.279
<v Speaker 2>repetitive code. It significantly reduces duplication compared to use account

444
00:23:32.319 --> 00:23:34.039
<v Speaker 2>for everything, so Forge.

445
00:23:33.720 --> 00:23:35.599
<v Speaker 1>Is better than count for dynamic sets.

446
00:23:35.599 --> 00:23:38.359
<v Speaker 2>Often yes, especially when the items you're creating aren't just

447
00:23:38.440 --> 00:23:41.720
<v Speaker 2>simple numbered sequences. It makes the state mapping clearer too.

448
00:23:41.920 --> 00:23:44.000
<v Speaker 2>And if we connect this to the bigger picture, you

449
00:23:44.039 --> 00:23:46.799
<v Speaker 2>can even use Terraform to deploy something like a multi

450
00:23:46.799 --> 00:23:50.599
<v Speaker 2>cloud monitoring solution. Use providers like data Dog or dyna

451
00:23:50.599 --> 00:23:55.519
<v Speaker 2>Trace to configure monitoring across say both AWS and Azure resources,

452
00:23:55.880 --> 00:23:59.599
<v Speaker 2>all from a single set of Terraform configuration files, centralized

453
00:23:59.599 --> 00:24:01.240
<v Speaker 2>observatability to find in code.

454
00:24:01.319 --> 00:24:04.119
<v Speaker 1>So it's about breaking things down logically with modules, then

455
00:24:04.160 --> 00:24:06.640
<v Speaker 1>building them back up dynamically with four each to handle

456
00:24:06.680 --> 00:24:10.039
<v Speaker 1>immense scale and complexity. How does all this tie into

457
00:24:10.119 --> 00:24:13.480
<v Speaker 1>automating deployments with CICD pipelines? That seems like the natural

458
00:24:13.519 --> 00:24:14.000
<v Speaker 1>next step.

459
00:24:14.279 --> 00:24:19.440
<v Speaker 2>Absolutely Implementing Terraform modules and configurations within CICD pipelines using

460
00:24:19.480 --> 00:24:22.599
<v Speaker 2>tools like get up actions, get lab, ci Jenkins, et cetera,

461
00:24:23.079 --> 00:24:26.640
<v Speaker 2>completely automates your infrastructure deployment processes.

462
00:24:26.160 --> 00:24:27.640
<v Speaker 1>Takes the manual workout and.

463
00:24:27.599 --> 00:24:32.000
<v Speaker 2>The manual errors. It makes deployments robust, reliable, repeatable, and

464
00:24:32.119 --> 00:24:36.400
<v Speaker 2>incredibly efficient. This enables teams to manage extremely complex infrastructures

465
00:24:36.440 --> 00:24:40.480
<v Speaker 2>at scale with confidence. What's fascinating here is that this

466
00:24:40.519 --> 00:24:44.000
<v Speaker 2>approach naturally fosters get ups, workflows, good ups. Yeah. Where

467
00:24:44.039 --> 00:24:48.039
<v Speaker 2>all infrastructure changes are proposed via pull requests, reviewed by peers,

468
00:24:48.119 --> 00:24:50.759
<v Speaker 2>automatically tested and plan in the pipeline, and then applied

469
00:24:50.799 --> 00:24:54.640
<v Speaker 2>upon merge. It brings the same rigorous software development practices,

470
00:24:55.039 --> 00:25:00.880
<v Speaker 2>version control, review testing, automation directly to your infrastructure management critical.

471
00:25:00.519 --> 00:25:04.880
<v Speaker 1>For collaboration, auditibility, and reducing human error. But with all

472
00:25:04.920 --> 00:25:08.359
<v Speaker 1>this automation and code defining everything, sensitive data becomes a

473
00:25:08.440 --> 00:25:11.480
<v Speaker 1>huge concern. How does Terraform handle secrets management? We can't

474
00:25:11.519 --> 00:25:12.480
<v Speaker 1>just put passwords in our.

475
00:25:12.440 --> 00:25:16.079
<v Speaker 2>Code, right, definitely not. This raises a really important question.

476
00:25:16.440 --> 00:25:21.119
<v Speaker 2>Security first. Always, the absolute golden rule is to always

477
00:25:21.200 --> 00:25:25.160
<v Speaker 2>use the sensitive intrue attribute for any variable or output

478
00:25:25.200 --> 00:25:26.400
<v Speaker 2>that contains secret data.

479
00:25:26.920 --> 00:25:28.160
<v Speaker 1>What does sensitive true do?

480
00:25:28.599 --> 00:25:31.200
<v Speaker 2>It tells Terraform to redact the value in its logs

481
00:25:31.480 --> 00:25:35.000
<v Speaker 2>and console output. It's a basic but essential first step,

482
00:25:35.559 --> 00:25:36.279
<v Speaker 2>but you need more.

483
00:25:36.720 --> 00:25:38.720
<v Speaker 1>Right, redaction is an encryption.

484
00:25:38.759 --> 00:25:42.240
<v Speaker 2>Exactly For a layered approach, you should integrate with dedicated

485
00:25:42.279 --> 00:25:47.039
<v Speaker 2>secrets management systems. Think AWS Secrets Manager as your key, Vault,

486
00:25:47.240 --> 00:25:49.519
<v Speaker 2>Google Secret Manager, or Hashi Corp.

487
00:25:49.400 --> 00:25:50.799
<v Speaker 1>Fault fault seems popular.

488
00:25:51.079 --> 00:25:54.160
<v Speaker 2>It is especially because Vault can provide dynamic secrets, short

489
00:25:54.200 --> 00:25:57.720
<v Speaker 2>lived credentials generated on demand, plus robust auditing and automatic

490
00:25:57.839 --> 00:26:02.720
<v Speaker 2>rotation capabilities. Crucially, securely inject these secrets into your CICD pipelines,

491
00:26:02.880 --> 00:26:05.799
<v Speaker 2>often using environment variables or built in integrations with these

492
00:26:05.839 --> 00:26:08.759
<v Speaker 2>secret managers, ensuring they never reside in plain text in

493
00:26:08.759 --> 00:26:11.200
<v Speaker 2>your code repository or state files if possible.

494
00:26:11.359 --> 00:26:13.640
<v Speaker 1>And Krummitti secrets, Terraform.

495
00:26:13.200 --> 00:26:16.640
<v Speaker 2>Can manage Kubernety secrets too, either using native functions or

496
00:26:16.839 --> 00:26:19.720
<v Speaker 2>again by integrating with Vault via tools like the Vault

497
00:26:19.799 --> 00:26:23.119
<v Speaker 2>Secrets Operator, which injects secrets directly into pods.

498
00:26:23.279 --> 00:26:27.559
<v Speaker 1>So a multi pronged approach mark sensitive use external managers

499
00:26:27.640 --> 00:26:28.519
<v Speaker 1>inject securely.

500
00:26:28.720 --> 00:26:31.680
<v Speaker 2>Got it? Okay, we've talked a lot about concepts and theory.

501
00:26:31.920 --> 00:26:35.880
<v Speaker 2>What are some concrete, real world use cases where terraform

502
00:26:35.920 --> 00:26:38.960
<v Speaker 2>really shines for advanced deployments showing its true impact.

503
00:26:39.119 --> 00:26:41.480
<v Speaker 1>Yeah, let's make it tangible. There are many, but let's

504
00:26:41.480 --> 00:26:45.400
<v Speaker 1>spotlight a few common powerful ones. First, Blue Green deployments.

505
00:26:45.839 --> 00:26:49.839
<v Speaker 1>Terraform can orchestrate these using services like AWS elastic load

506
00:26:49.839 --> 00:26:51.720
<v Speaker 1>balancing and autoscaling groups.

507
00:26:51.799 --> 00:26:52.480
<v Speaker 2>How does that work?

508
00:26:52.559 --> 00:26:56.240
<v Speaker 1>You basically have two identical environments, blue and green. Terraform

509
00:26:56.279 --> 00:26:59.200
<v Speaker 1>deploys the new version to the inactive environment, say Green,

510
00:26:59.440 --> 00:27:01.759
<v Speaker 1>you test it, but then Terraform just flips the load

511
00:27:01.759 --> 00:27:05.200
<v Speaker 1>balance or traffic over. This allows for zero downtime deployments

512
00:27:05.240 --> 00:27:07.920
<v Speaker 1>and super easy rollbacks, just flip the traffic back if

513
00:27:07.960 --> 00:27:08.640
<v Speaker 1>something goes wrong.

514
00:27:08.720 --> 00:27:14.759
<v Speaker 2>Seamless updates nice. What else? Automating database migrations with say AWSRDS,

515
00:27:15.319 --> 00:27:18.200
<v Speaker 2>You could define your database schema changes as code like

516
00:27:18.240 --> 00:27:22.000
<v Speaker 2>sequal scripts and use Terraform's null resource with local exec

517
00:27:22.119 --> 00:27:25.119
<v Speaker 2>or remote exec provisioners to run those scripts against the

518
00:27:25.279 --> 00:27:28.880
<v Speaker 2>RDS instance as part of your Terraform apply. Ensures consistent

519
00:27:28.920 --> 00:27:32.079
<v Speaker 2>and reliable migrations tied to your infrastructure.

520
00:27:31.480 --> 00:27:34.440
<v Speaker 1>Changes interesting infrastructure and schema together.

521
00:27:34.680 --> 00:27:38.200
<v Speaker 2>Then there's serverless. Terraform is great for deploying serverless applications

522
00:27:38.240 --> 00:27:43.559
<v Speaker 2>on platforms like AWS, Lambda and API, Gateway, managing function code, triggers, permissions, everything.

523
00:27:43.759 --> 00:27:48.079
<v Speaker 2>It really shows its reach into managing modern event driven architectures. Okay,

524
00:27:48.240 --> 00:27:52.599
<v Speaker 2>and finally, maybe the ultimate safety net automating disaster recovery.

525
00:27:53.640 --> 00:27:57.720
<v Speaker 2>Terraform can define a comprehensive DR strategy, replicating resources across regions,

526
00:27:57.960 --> 00:28:01.880
<v Speaker 2>setting up automated failover mechanisms using services like AWS elastic

527
00:28:01.920 --> 00:28:06.200
<v Speaker 2>disaster recovery DRS, configuring S three for backups, using cloud

528
00:28:06.200 --> 00:28:08.759
<v Speaker 2>watch events, and Lambda functions to trigger fail over logic,

529
00:28:09.200 --> 00:28:10.920
<v Speaker 2>all defined and managed a code.

530
00:28:11.079 --> 00:28:15.359
<v Speaker 1>Wow, those are some serious real world impacts from seamless

531
00:28:15.400 --> 00:28:20.200
<v Speaker 1>deployments to full scale disaster recovery plans written in code. Finally,

532
00:28:20.279 --> 00:28:24.519
<v Speaker 1>let's be realistic when things inevitably go wrong in complex configurations,

533
00:28:24.519 --> 00:28:28.079
<v Speaker 1>because they always do. Eventually, what are the essential advanced

534
00:28:28.119 --> 00:28:31.319
<v Speaker 1>debugging techniques you need in your toolkit to quickly find

535
00:28:31.319 --> 00:28:32.200
<v Speaker 1>and fix the problem?

536
00:28:32.319 --> 00:28:36.160
<v Speaker 2>Yeah, debugging is a critical skill. First detailed logging. Setting

537
00:28:36.240 --> 00:28:40.240
<v Speaker 2>the tflog environment variable usually to trace. T flog trace

538
00:28:40.519 --> 00:28:44.480
<v Speaker 2>provides extremely verbose output. They can reveal exactly what terraform

539
00:28:44.559 --> 00:28:47.519
<v Speaker 2>is doing, what API calls its making, and where errors

540
00:28:47.519 --> 00:28:50.319
<v Speaker 2>are occurring. It's noisy, but invaluable.

541
00:28:50.359 --> 00:28:52.000
<v Speaker 1>Okay, churn on the fire hose pretty much.

542
00:28:52.200 --> 00:28:55.720
<v Speaker 2>Second state inspection. You'll rely heavily on commands like terraform

543
00:28:55.720 --> 00:28:58.759
<v Speaker 2>show to see the current state and terraform states. Terraform

544
00:28:58.799 --> 00:29:01.400
<v Speaker 2>state show resource to exams specific resources in the state

545
00:29:01.440 --> 00:29:05.039
<v Speaker 2>file and reconcile what Terraform thinks exists with reality check

546
00:29:05.039 --> 00:29:09.759
<v Speaker 2>in its memory exactly. Third, plan analysis, Sometimes the plan

547
00:29:09.799 --> 00:29:13.599
<v Speaker 2>itself is confusing. Running Terraform show dash jasumplan dot out

548
00:29:13.680 --> 00:29:16.519
<v Speaker 2>JKE lets you pipe the plan output save to a

549
00:29:16.559 --> 00:29:19.200
<v Speaker 2>file into a tool like JKE to parse the JASON

550
00:29:19.519 --> 00:29:22.799
<v Speaker 2>and inspect the plan changes in excruciating detail before you.

551
00:29:22.799 --> 00:29:24.839
<v Speaker 1>Apply them digging into the JSON YEP.

552
00:29:25.319 --> 00:29:30.160
<v Speaker 2>And Fourth, for surgical precision when troubleshooting targeted operations, using

553
00:29:30.240 --> 00:29:33.960
<v Speaker 2>terraform plan dash target resource dot type, dot name or

554
00:29:34.200 --> 00:29:37.559
<v Speaker 2>Terraform applied dish target allows you to focus terraforms actions

555
00:29:37.839 --> 00:29:41.680
<v Speaker 2>on only specific resources or modules, which can drastically speed

556
00:29:41.759 --> 00:29:44.960
<v Speaker 2>up testing fixes without affecting the whole stack. These techniques

557
00:29:45.000 --> 00:29:48.480
<v Speaker 2>are vital for navigating and resolving issues in complex setups efficiently.

558
00:29:48.640 --> 00:29:51.279
<v Speaker 1>What a journey. We've really navigated the vast landscape of

559
00:29:51.359 --> 00:29:54.079
<v Speaker 1>terraform here, haven't we, from its foundational principles right through

560
00:29:54.119 --> 00:29:57.960
<v Speaker 1>to its most advanced applications. Pulling practical recipes and some

561
00:29:58.079 --> 00:29:59.960
<v Speaker 1>eye opening insights directly from the terraform.

562
00:30:00.559 --> 00:30:01.759
<v Speaker 2>We really covered a lot of ground.

563
00:30:02.000 --> 00:30:07.039
<v Speaker 1>You've seen how terraform truly transforms infrastructure into something predictable,

564
00:30:07.279 --> 00:30:11.759
<v Speaker 1>version controlled, basically an asset you manage like software. It

565
00:30:11.799 --> 00:30:17.000
<v Speaker 1>empowers you to build resilient, scalable, and hopefully secure systems.

566
00:30:17.119 --> 00:30:21.000
<v Speaker 2>Indeed, it's a fundamental shift moving us away from those manual,

567
00:30:21.240 --> 00:30:25.119
<v Speaker 2>error prone processes to something far more reliable and automatable.

568
00:30:25.559 --> 00:30:27.279
<v Speaker 2>And if we connect this to the bigger picture, you

569
00:30:27.319 --> 00:30:31.359
<v Speaker 2>consider this, If your entire infrastructure can be written, tested

570
00:30:31.400 --> 00:30:34.440
<v Speaker 2>and deployed just like any other piece of software, what

571
00:30:34.519 --> 00:30:38.599
<v Speaker 2>new possibilities does that unlock? Think about rapid innovation, experimentation

572
00:30:39.000 --> 00:30:42.880
<v Speaker 2>moving faster. But conversely, what forgotten risks might we inadvertently

573
00:30:42.920 --> 00:30:46.000
<v Speaker 2>be encoding into our digital world If we're not careful

574
00:30:46.000 --> 00:30:49.839
<v Speaker 2>with that code, are we building fragile monoliths without realizing it?

575
00:30:50.000 --> 00:30:53.960
<v Speaker 1>That's a powerful thought to chew on security complexity. It's

576
00:30:54.000 --> 00:30:56.920
<v Speaker 1>all in the code. Now, the world of infrastructure's code

577
00:30:56.960 --> 00:31:00.640
<v Speaker 1>is constantly evolving. What stood out to you listening today

578
00:31:00.640 --> 00:31:02.880
<v Speaker 1>from this deep dive? What's the next recipe? Maybe you're

579
00:31:02.880 --> 00:31:04.400
<v Speaker 1>excited to try in your own environment.

580
00:31:04.839 --> 00:31:07.039
<v Speaker 2>Yeah, hopefully there were some useful nuggets in there.

581
00:31:07.240 --> 00:31:10.920
<v Speaker 1>Keep exploring, keep questioning, and keep deep diving into the

582
00:31:11.000 --> 00:31:11.880
<v Speaker 1>power of code.
