Are you a DevOps Engineer?

Learn how to boost your productivity and reduce your workload with ChatGPT!

ChatGPT has changed the way people develop code and create solutions. Software and DevOps Engineers are starting to use ChatGPT to improve their work.

If you’re a DevOps Engineer, this post is for you! In this article we’ll look at ways in which you can incorporate ChatGPT in your daily workflow to make your work easier to boost your productivity as well as some tips to best communicate with ChatGPT in order to get the best results and avoid mistakes.

How can you use ChatGPT in an actual world DevOps project?

  1. Automate repetitive tasks:

    ChatGPT can be used to automate repetitive tasks such as deploying code to servers, running tests, and monitoring systems. This can save DevOps engineers a lot of time and allow them to focus on more important tasks.

    You can, for example, ask ChatGPT to create a bash script to take your MySQL database backup everyday and store it on S3. This will save time and will prevent errors, increasing your productivity and workload.

    The most impressive thing is that ChatGPT will not only create the code, but break it down for you, explaining every step, which is particularly useful if you are a beginner.

  2. Understand code and application logs

    Being a Software engineer you have to often review application code. Sometimes it can be code that has been written by other members of the team and reviewing all of it can be a weary and complex task.

    Just by pasting a code block and adding a simple command like “Explain the following code to me”, ChatGPT will proceed to give you detailed, step by step information about the code you entered and all its functions.You can even paste Docker Container logs into the chat and ask ChatGPT to give you a summary of what the its content.


    You can be as general or as specific as you like depending on your needs. If you are having problems with the code, need clarification or assistance debugging it, you can try the following steps:

    • Clarify technical terms:
      If you come across technical terms in your code or application logs that you don’t understand, you can ask ChatGPT to explain them to you. For example, you could ask “What is a stack trace?” or “What is a segmentation fault?” and ChatGPT can provide you with a clear explanation.

    • Debugging assistance:
      If you’re having trouble with a specific error or issue in your code or application logs, you can describe the problem to ChatGPT and it can help you diagnose the issue. You can provide ChatGPT with specific error messages or symptoms and ask for suggestions on how to fix the problem.


    • Understanding code flow:
      If you’re working with complex code or trying to understand how a particular piece of code works, you can ask ChatGPT to explain the flow of the code to you. For example, you could ask “Can you explain how this function works?” and ChatGPT can provide you with an explanation of the function and its behavior.


    • Troubleshooting guidance:nderstand code and application logs:
      If you’re experiencing issues with your application and you’re not sure where to start, you can describe the symptoms to ChatGPT and it can suggest possible causes and solutions. For example, you could describe a specific error message or behavior and ask “What could be causing this?” and ChatGPT can provide you with possible explanations and solutions.
  3. Create better documentation for your applications:
    Creating a clear guide so that users can easily understand and utilize an application you have developed is not as simple as it sounds. This is another task that can be very time consuming and can easily be delegated to our AI assistant ChatGPT.

    ChatGPT is capable of retaining information from previous conversations, which means that if you had been using ChatGPT to help you create your application, it already knows about it and can write the documentation for it. Otherwise, you can provide it with a prompt or a series of prompts related to the specific aspect of the application you want to document. 

    Again, you can go very general asking ChatGPT to “create the documentation for x application” to which ChatGPT will write a short description, make a list of all its features and describe how to get started with it. 

    But you can also go more specific, asking ChatGPT to create more detailed explanations of the application in several ways. Here are some examples:

    • Generate explanations: You can use ChatGPT to generate explanations for different features of your application. For example, you can ask ChatGPT to explain how a particular feature works or how to use a particular function within the application. This can help you create detailed documentation that is easy to follow.

    • Create FAQs: You can use ChatGPT to create a list of frequently asked questions (FAQs) for your application. This can help users quickly find answers to common questions and reduce the need for support.

    • Write tutorials: You can use ChatGPT to write step-by-step tutorials on how to use your application. These tutorials can cover different aspects of your application and help users learn how to use it effectively.

    • Create user manuals: You can use ChatGPT to create user manuals for your application. These manuals can provide comprehensive documentation on how to use your application, including screenshots, diagrams, and other visual aids.

    You can then fine-tune the generated text to ensure that it meets your requirements and is accurate and easy to understand.

  4. Code Conversion:
    You can enhance the versatility of your project and save yourself time by asking ChatGPT to convert code for you when you need it. ChatGPT’s ability to accurately convert code from one language to another may depend on various factors, such as the complexity of the code and the target language or format.

    You can use it to convert your code to a variety of languages and formats. You can, for example, use ChatGPT to convert a Gitlab CI pipeline into a Jenkins CI/CD pipeline. 

    Here are some more examples:

Converting Python code to JavaScript:

You can ask ChatGPT to convert a Python code snippet to JavaScript by providing the Python code as input and specifying the target language as JavaScript. For example, you could say “Convert this Python code to JavaScript” and provide a code snippet like:

ChatGPT could then provide you with the equivalent JavaScript code:


Converting JSON data to YAML:

You can ask ChatGPT to convert JSON data to YAML format. For example, you could say “Convert this JSON data to YAML” and provide a JSON data snippet like:

ChatGPT could then provide you with the equivalent YAML data:


Converting HTML code to Markdown:

You can ask ChatGPT to convert HTML code to Markdown format. For example, you could say “Convert this HTML code to Markdown” and provide an HTML code snippet like:

ChatGPT could then provide you with the equivalent Markdown code:

You can see in some of these examples, that ChatGPT is not exempt of making mistakes, this time not on the code, but on the some of the lables of the code snippets.

  1. Create a whole infrastructure setup
    We asked ChatGPT to “Create terraform code with an AWS VPC having private and public subnet, attach internet gateway and NAT gateways to the subnets and also launch an instance inside the public subnet”.

ChatGPT answered:

Sure, here’s an example Terraform code that creates an AWS VPC with private and public subnets, attaches an internet gateway and NAT gateway to the subnets, and launches an EC2 instance inside the public subnet:

Note that you’ll need to replace the region, ami, and vpc_security_group_ids values with appropriate values for your environment.

ChatGPT Tips and tricks

All and all GhatGPT has proven to be a very versatile tool that, when used correctly can help you save a lot of time increasing your efficiency and reducing your workload.

But if there is something you don’t want, it is to use ChatGPT’s help to create a code that you will later have to spend hours debugging! You want to make sure to be using ChatGPT to the best of its ability so that it makes your work easier and not harder.

How do you do that? Let’s find out!

Tips and Tricks to get the most out of using ChatGPT for DevOps

  1. Use it as a supplement, not a replacement: ChatGPT can be helpful in automating certain tasks, such as generating code or providing documentation, but it’s important to remember that it’s not a replacement for human expertise. Use ChatGPT to supplement your own knowledge and skills, not replace them entirely.


  2. Provide clear and specific prompts: When using ChatGPT to generate code or provide recommendations, make sure to provide clear and specific prompts to ensure the output is accurate and relevant. Vague or ambiguous prompts can result in irrelevant or incorrect results.


  3. Specify Versions: ChatGPT does not always take an application’s last version by default. If you need to generate configuration based on a tool or language that has multiple versions, specifying which version you want ChatGPT to use, can save you a lot of trouble. The more specific you are in your request, the more accurate results you will get. For example, if you need Python2 and not Python3 code, you should explicitly ask for it.


  4. Use it for repetitive or time-consuming tasks: As we saw above, ChatGPT can be particularly useful for automating repetitive or time-consuming tasks, such as generating code snippets or providing documentation. This can save time and improve efficiency.


  5. Verify and test the output: Always verify and test the output generated by ChatGPT before implementing it into your project. This will help catch any errors or issues that may have been missed by the AI model.


  6. Give examples: A lot of people forget the power of giving examples to ChatGPT in order to increase the probability of its response meeting your needs more accurately. We can control how ChatGPT’s responds using roles, providing it with information instead of letting it guess or fill in the blanks, is always better.


    Here is an example:
    Let’s see what happens if instead of asking: regex to find an ip address in a string which may yield, you type something more specific like:  regex to find an ip address in a string, for example, in a url string the regex should match

ChatGPT answered:

Here’s a regex that will match an IPv4 address within a string:

In the context of a URL, you can modify this regex to only match IPv4 addresses that appear before the port number, like so:

Here’s a breakdown of how the regex works:

  • \b matches a word boundary, to ensure that the match doesn’t occur within a larger sequence of digits
  • (?:\d{1,3}\.){3} matches three sequences of one to three digits followed by a period, but the (?: ) syntax indicates a non-capturing group (i.e., we’re not interested in capturing the individual components of the IP address)
  • \d{1,3} matches a final sequence of one to three digits
  • (?=:) is a positive lookahead that matches the final digit sequence only if it is followed by a colon (i.e., the port number)

With this regex, if you apply it to the example URL ““, it will match the IPv4 address “”.

7. Try other Ai assistants:

If you come to a dead end with ChatGPT you can also try using other tools, such as OpenAI’s Playground.

Some more ChatGPT best practices

Keep the model up to date:

ChatGPT is constantly learning and improving based on new data, so it’s important to keep the model up to date to ensure the best results. Stay informed about any updates or changes to the model and adjust your usage accordingly.


Ensure data privacy and security: 

When using ChatGPT, ensure that any sensitive data or information is kept private and secure. Avoid using it for tasks that involve sensitive or confidential information, and be aware of any potential risks or vulnerabilities that may exist.