Mysterious missing “region” argument in Terraform

I’m working on my next course for Pluralsight, Implementing Terraform on AWS. I probably don’t need to explain what the course is about. Anyhow, I was trying to show how you can create multiple instances of an AWS provider using the alias argument. Running through the initialization and validation process I ran into an error that was not very helpful.

Error: Missing required argument

The argument "region" is required, but was not set.

No mention of what line the error occurred on, or what resource in the configuration was throwing it. Just a missing region argument. Let’s see what’s going on here.

Continue reading “Mysterious missing “region” argument in Terraform”

The Terraform Certified Study Guide

As I mentioned in a previous post, HashiCorp has officially announced the availability of two certifications, Terraform Certified Associate and Vault Certified Associate. In that post I detailed a bunch of different resources to help you study for the Terraform exam. One of those resources was a study guide that Adin Ermie and I put together called the HashiCorp Terraform Certified Associate Preparation Guide, which does not lend itself well to an acronym – HTCAPG? I guess we could go with Hat Cap? Nah. Anyway, I thought I would give you an idea of what is in the guide, and a free sample of a few pages.

Continue reading “The Terraform Certified Study Guide”

Preparing for the HashiCorp Terraform Certification

HashiCorp has recently announced the availability of the Terraform Certified Associate exam. This is an excellent way to assess your skills and demonstrate your competence with the Infrastructure as Code tool, Terraform. Those who have been following me for any period of time know that I am a pretty big fan of Terraform, and may have authored more than a few posts and courses on the topic. What you might not know is that I was actively involved in writing and reviewing the questions for the exam. In this post, I will give you an overview of what to expect in the exam, how I think you should study for it, and some materials to help you along the way.

Continue reading “Preparing for the HashiCorp Terraform Certification”

Terraform – FotD – Wrap Up

This is the final post of an ongoing series of posts documenting the built-in interpolation functions in Terraform. For more information, check out the beginning post. In this post I would like to take a moment to review the project as a whole, mung together some semi-coherent thoughts about the functions, and maybe even make a plan for the future.

Thoughts on the project

In June of this year, I undertook a project to examine each built-in interpolation function within Terraform. My plan was to examine a function each day – weekends excluded – and document how the function works, why it might be useful, and any interesting tidbits I discovered along the way. There were a few drivers behind the project:

  • I was not consistently blogging, and taking on a daily blogging project would force me to do so.
  • There were several functions that I did not understand in Terraform, and this seemed like a good way to learn.
  • I’ve got a couple courses on Pluralsight dealing with Terraform and I thought this would help when I revise them.

I’d like to say that I had thought this whole process through and started my first post with the whole series and format laid out. I’d like to say that, but it wouldn’t be the truth. The first few posts had me working through the format of the post and the way in which I wanted to create examples. It also took me a few iterations to figure out how I wanted to structure the GitHub repo, and how to effectively create new examples with minimum effort. After the first few posts I got into a groove. I also realized that this was going to be a significant undertaking in terms of time. When I started the posts, there were about 63 functions, and now there are 65. Working at five functions a week, the whole thing should have taken about 13 weeks to complete. That’s three months of posting, five days a week. Considering I started in June and finished in September, three months was exactly right. It wasn’t till the end of the first week that I realized that I had made a three month commitment, and once I did realize that, I started to look for ways to make the process sustainable. Using a basic template for posting and examples helped a lot. I also didn’t get too ambitious with the number of examples for each function. I wouldn’t say that the process was easy, and I don’t know if I would do it again. But I will say that I learned a lot about Terraform and blogging.

Thoughts on Terraform functions

If I could start the whole project over again, I would have grouped the functions by what they do, and not alphabetically. It makes sense to put all the functions dealing with strings together, and same with lists and maps. Then there are the functions that take no arguments. Basically, if you are looking for a function to assist with string manipulation, then it would be much more helpful if all of those types of functions were grouped together. So here’s my attempt at doing exactly that:

Terraform Interpolation Function Cheat Sheet

String functions

Number and date functions

List functions

Map functions

File and path functions

Network functions

Security and web functions

Thoughts on Terraform and the future

While writing all of these posts, I did discover some things I would like to see changed and improved. For instance, the documentation page for the built-in functions is listed alphabetically for the most part. But there are a few examples of it not being entirely alphabetical. That’s a minor thing to most. As the son of a librarian, that’s the type of thing that really gets stuck in my craw. More importantly, I think the functions should be grouped by loose affiliation; the way I just listed them out. There were also a few functions that I thought were either missing functionality, or could be improved in some way. I don’t want to be the person just complaining about things, I want to be part of the solution as well. The whole project is open source, including the docs. The website is written in markdown, and I can easily update the page with the built-in functions and submit a pull request. In fact, I plan to do that. The functions are written in Golang, and that makes things a little trickier since I am not a developer by trade. To that end, I have started learning Golang in order to assist with improving the functions. My first attempt was adding a function called dateadd that would add the ability to manipulate dates in the same way that timeadd deals with time. After submitting my pull request, I had some good conversations with one of the maintainers about whether that should be a separate function or added to the timeadd function. We agreed on adding it to the timeadd function and I am working on learning enough Go to make that a reality.

Terraform v0.12 will be dropping in the near future. It is going to bring with it a lot of enhancements to the Hashicorp Configuration Language, and the way that Terraform functions overall. There will be breaking changes, but it will all be in the name of creating a better product. Terraform is becoming more widely adopted by the moment, and it’s probably best to make the necessary changes now before this juggernaut picks up any more steam. I’m sure once the new version drops I will need to revise my courses on Pluralsight and maybe review some new functions here. I’m excited for the future and what it might bring!