During the keynote at HashiConf 2023 Armon Dadgar, HashiCorp’s Co-Founder and CTO, humorously quipped:

Nowadays there wouldn’t be a keynote unless you mention AI at least once

To be fair, I don’t remember the quote verbatim so take it with a grain of salt. However, the message he conveyed is captured in my rendition of the quote.

There were two AI-related announcements made during the keynote. The first was about automatic test generation for a module inside of Terraform Cloud. This was a part of the new test framework announcement, one that I covered in my previous post. The other announcement, which I will focus on in this post, was the Developer AI. The Developer AI is part of developer.hashicorp.com.

Developer AI introduces itself as:

Your AI-powered companion for finding reference materials, architectural guidance, and product examples from HashiCorp. Ask me anything to get started.

To get started using Developer AI you need to sign-up for the private beta, you can sign up at hashi.co/dev-ai-signup1. Once you are in the private beta you can head on over to developer.hashicorp.com or specifically to your favorite product documentation. I am a huge fan of Terraform, so to try out Developer AI I pointed my browser at developer.hashicorp.com/terraform.

Developer AI hides in the search field in the upper right corner:

search box 1

To open the search interface I can click on the search box, or press Command + K on my keyboard (since I am using a Mac, but you would press ctrl + K on a different kind of computer). The search interface contains a lot more than the Developer AI, but that is currently of no interest to me so instead I click on the Ask Developer button:

search box 2

Finally I am ready to interact with Developer AI:

search box 3

You are informed in the UI that Developer AI have the following features:

  • Personalized recommendations
  • Natural language conversations
  • Tap into HashiCorp knowledge base

The point about personalized recommendations will probably not work out-of-the-box since this is the first time I am using Developer AI. Perhaps if I use it a lot it will learn my personal preferences. As with any AI these days there is also a disclaimer in the UI:

Content generated by Developer AI may contain errors, inconsistencies, or outdated information. It is provided as-is without any warranties or guarantees of accuracy. Use of this feature and related content is governed by HashiCorp’s AI Policy.

As with other AIs this one might hallucinate, but unless you have lived under a rock the past year you are most likely aware of this. Always keep this in mind when communicating with an AI!

What do I want to ask Developer AI? Let’s see if it can suggest any good way of parsing data stored in a CSV file for further use in Terraform! This is a problem I happened to encounter once2. I enter my question in the text box and press send:

asking

Developer AI immediately generates the following reply for me:

To parse data stored in CSV files for use in Terraform, you can use the csvdecode function provided by Terraform. This function allows you to read and parse CSV files directly within your Terraform configuration.

Here’s an example of how you can use the csvdecode function:

First, you need to read the CSV file using the file function and assign it to a variable:

locals {
  csv_data = file("${path.module}/data.csv")
}

Next, you can use the csvdecode function to parse the CSV data:

locals {
  parsed_data = csvdecode(local.csv_data)
}

Now, you can access the parsed data in your Terraform configuration. For example, if your CSV file has columns named "name" and "age", you can access the values like this:

resource "aws_instance" "example" {
  count = length(local.parsed_data)

  instance_type = local.parsed_data[count.index].name
  ami           = local.parsed_data[count.index].age
}

In this example, we assume that the CSV file has a header row with column names "name" and "age". The csvdecode function will parse the CSV data and create a list of objects, where each object represents a row in the CSV file. You can then access the values of each column using dot notation.

Remember to adjust the file path in the file function to match the location of your CSV file.

By using the csvdecode function, you can easily parse CSV data and use it in your Terraform configuration. This can be useful for dynamically generating resources or configuring variables based on data stored in CSV files.

For more information, you can refer to the Terraform documentation on the csvdecode function: Terraform csvdecode function

This might sound fabricated to increase the legitimacy of Developer AI, but I genuinely did not know the csvdecode function existed! I would call this response a great success! I also feel a little dumb because that function might have made my life easier back when I was in the situation where I needed it2.

Since I am a responsible private beta participant I provide feedback to the response by clicking the thumbs-up button.

asking

The next time I am performing complicated manipulations in Terraform, or doing anything that I don’t know by heart, I will take Developer AI for another spin. This has been my first interaction and I am pleased with the results!


  1. Thanks to Serhii Vasylenko for reminding me about the link to the beta signup ⭐️ ↩︎

  2. If you know, you know. ↩︎ ↩︎