[Knowledge Edition] Codifying infrastructure configuration. Learn the concept of "infrastructure as code" to make configuration management smarter

table of contents
Hi, I'm Teraoka, an infrastructure engineer.
The theme of this blog post is infrastructure as code
. I was thinking about what to write, and it ended up being longer than I expected, so I've decided to split it into a knowledge section and a technology section.
First, the knowledge section.infrastructure as codeI'll start by explaining what
■What is “infrastructure as code”?
In short,coding your infrastructure configuration. (That's pretty straightforward, even Google Translate would be surprised!)
These days, cloud services like AWS are mainstream, so
building or modifying infrastructure is usually done with a few clicks on a GUI screen. But
Infrastructure as Code,that's not how it works.
like a program,as code,write
and then deploy it using a dedicated tool to build your infrastructure.
There's a dedicated tool called "Terraform,"
which I'll introduce in the technical section! (I'll write about it on my blog later.)
■Why "code" in the first place?
You wouldn't do something like this if there was no benefit, right? (There are definitely benefits.)
To summarize, it's as follows:
Automating infrastructure construction
This is perhaps the biggest advantage.
When you need to build multiple servers with the same configuration,
doing it manually often involves a lot of repetition.
Do you really have to repeat the exact same work for each server? You'd rather not, right?
In the previous section, I wrote the following:
by writing everything as "code," just like a program, and then
deploying it using specialized tools.
The infrastructure configuration you want to build is already written as code, so
all you have to do is tell the dedicated tool, "Please build it like this." Everything else is done automatically.
Furthermore, because it only involves executing code, anyone performing the taskwill always get the same result.
This alsohelps prevent human error.
Centralized management of infrastructure configuration
When building or modifying infrastructure, it
is essential to document the current configuration and when and which parts were changed.
(These are often referred to as design documents or procedure manuals.)
Without these documents, it becomes impossible to know the current configuration.
(And when this is lost, operational errors are bound to occur.)
Furthermore, when creating design documents or procedure manuals,
it's essential to update them with the latest information after each task.
This is because the next time the same task is performed, the document will be referenced.
However, since this is done manually, mistakes are inevitable.
It's easy to forget to update the documents.
This can lead to situations where the document content and the actual structure somehow differ. It
the last person to update the document was a predecessor who has already left the project
would be even worse if
Infrastructure as Codeinvolves
building infrastructure based on pre-written procedure manuals in the form of code. Because any
configuration changes require editing the code, forgetting to update is virtually impossible.
just like with program source codepossible to manage versions using tools like Git,.
■It's convenient, but there are some concerns
The cost of learning will naturally increase
If you can't write code, you can't even change the configuration in the first place.
Furthermore, you'll need to learn how to use the deployment tools.
This will undoubtedly increase the learning curve.
Is this the era where infrastructure engineers can't do their jobs without being able to write code...?
The code gives an unexpected error
If there are errors in the code, it will stop with an error (just like any other programming language).
Deploying with errors is bad for your mental health, so
prevents knowledge from becoming tied to specific individuals by sharing the code on GitHub or similar
allows for constant monitoring by a third party to spot errors.
Summary
To be honest, the knowledge section is just about reading long sentences (
I think it's an attractive idea if you can understand the system properly and operate it properly
Above all, the term "infrastructure as code" sounds cool
...Enough joking, next time we'll get to the technical part, so let's get to work. Stay tuned!!
2
