Doing DevOps Like Skynet with ChatGPT

Eran Bibi

ChatGPT has been dominating all of our feeds over the last week, and blowing people's minds. We took it for a test drive to see if it could do DevOps...you gotta see this in action.

Source:
Terminator movie

If you've been anywhere on the interwebs in the last week, you have likely heard about ChatGPT. OpenAI announced the next generation of their natural language processing AI model, called ChatGPT–that you can chat with about basically any topic under the sun.

People have been updating their avatars with AI generated avatars, based on ChatGPT-created prompts, and posting endless screenshots of their disbelief at the quality and breadth of ChatGPT's knowledge.

Here are just a few examples of what ChatGPT is capable of:

One area that really has the tech industry taken by storm is ChatGPT's capability of writing code. Some have even claimed that it will replace Google and Stack Overflow. We found this intriguing and wanted to see how it holds up with infrastructure configuration. So we took ChatGPT on a test drive.

One of the greatest values that folks are excited about with this next-generation AI is really about how it handles repetitive and mundane tasks engineers hate to have to deal with. One such area is IaC templates - so our first attempt was to see how ChatGPT would deliver on creating an IaC template and modules.

Let's take a look.

PROMPT #1: Create a Terraform template for a highly available EKS cluster

And the results are:

Very cool! Should I be looking for a job? Probably not yet… but It's incredible to see how accurate ChatGPT is and its capabilities of writing infrastructure code with limited prompts. 

However, all due respect, let’s see if it’s up to the challenge of an imperative IaC like Pulumi.

Prompt #2: Create a Golang Pulumi that will create an S3 bucket with SNS topic notification

What you can see in this code, is that it uses the AWS Go SDK and the Pulumi AWS package to create an S3 bucket and an SNS topic. It then adds a subscription to the SNS topic using the s3.NewBucketNotification function.  An added step that is important and wasn’t directly requested.  Impressive.

Let’s dig even deeper.  It would be interesting to see how ChatGPT manages repetitive but multi-step configuration workflows, such as CI/CD pipelines. although, I will be more specific with my ask this time.


Prompt #3: Create a Jenkins pipeline that will clone the code, scan it using Trivy, run Infracost and plan and apply infrastructure using Terraform

Now trying with GitHub Actions pipeline

Prompt #4: Create a Github Action that applies terraform code and send me slack notification once done

Aside from the fact that ChatGPT uses an outdated version of Terraform (0.12.29), which is easily fixable with a small minor edit, the pipeline is what I was expecting. It put an outdated version probably because it has limited knowledge of the world and events after 2021, I assume that one day ChatGPT will know that Terraform already released v1.x .

So What's the Verdict?

ChatGPT is pretty amazing.  While the haters will talk about its shortcomings, have whatever opinions you may about Elon Musk, others see this as a new (and possibly scary) future:

I, for one, welcome the machine overlords to manage the machines that manage us and our time today.

What do you think?