
ChatGPT is a cutting-edge language model developed by OpenAI that has been trained on a massive corpus of text data. With its advanced artificial intelligence capabilities, it can generate human-like responses to a wide range of questions and statements. Whether you need information on a particular topic, help with a problem, or just want to have a conversation, ChatGPT is the perfect tool for you. So why wait? Try ChatGPT today and experience the power of AI-powered conversation!. In this article, we will exlore How OpenAI replaces daily works of an Software Engineer.
I started as a DevOps engineer years ago and most of time was working with command-line interface to create cloud resources. But one day I heard about chatGPT which has abilities creating my daily work with some command as natural language. This is my short story showing how I apply chatGPT (OpenAI bot) to my work.
What I want to do ?
I want to have a Github workflow which create an Azure VM with input parameters for vm name, location, size, … under a specify resource group.
What was happening ?
1. I asked chatGPT for creating with unclear question.
create a Github workflow which create an Azure VM with input parameters: vm name, location, vm size
this is the first response
name: Create Azure VM on: push: branches: - main env: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} jobs: create_vm: name: Create VM runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/[email protected] - name: Set up Azure CLI uses: azure/[email protected] with: azure-cli-version: latest - name: Login to Azure uses: azure/[email protected] with: credentials: ${{ env.AZURE_CREDENTIALS }} - name: Create VM run: | az vm create --resource-group myResourceGroup --name ${{ env.VM_NAME }} --location ${{ env.LOCATION }} --size ${{ env.VM_SIZE }} --image UbuntuLTS --generate-ssh-keys env: VM_NAME: ${{ env.VM_NAME }} LOCATION: ${{ env.LOCATION }} VM_SIZE: ${{ env.VM_SIZE }}
2. It looks fine but I need correct something
let’s make environment variables becomes input parameters
2nd response
name: Create Azure VM on: push: branches: - main env: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} inputs: vm_name: description: The name of the virtual machine required: true location: description: The location where the virtual machine will be created required: true vm_size: description: The size of the virtual machine required: true jobs: create_vm: name: Create VM runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/[email protected] - name: Set up Azure CLI uses: azure/[email protected] with: azure-cli-version: latest - name: Login to Azure uses: azure/[email protected] with: credentials: ${{ env.AZURE_CREDENTIALS }} - name: Create VM run: | az vm create --resource-group myResourceGroup --name ${{ inputs.vm_name }} --location ${{ inputs.location }} --size ${{ inputs.vm_size }} --image UbuntuLTS --generate-ssh-keys
3. As a Azure cloud engineer, I know the resource group should be created first so I asked chatGPT corrects this by
let’s create azure resource group for virtual machine first
3rd response
name: Create Azure VM on: push: branches: - main env: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} inputs: vm_name: description: The name of the virtual machine required: true resource_group_name: description: The name of the resource group to create or use for the virtual machine required: true location: description: The location where the virtual machine will be created required: true vm_size: description: The size of the virtual machine required: true jobs: create_vm: name: Create VM runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/[email protected] - name: Set up Azure CLI uses: azure/[email protected] with: azure-cli-version: latest - name: Login to Azure uses: azure/[email protected] with: credentials: ${{ env.AZURE_CREDENTIALS }} - name: Create Resource Group run: | az group create --name ${{ inputs.resource_group_name }} --location ${{ inputs.location }} - name: Create VM run: | az vm create --resource-group ${{ inputs.resource_group_name }} --name ${{ inputs.vm_name }} --location ${{ inputs.location }} --size ${{ inputs.vm_size }} --image UbuntuLTS --generate-ssh-keys
4. It looks greats but there’s a wrong code, so I asked again for update
inputs should be moved under workflow_dispatch section
4th updates
name: Create Azure VM on: workflow_dispatch: inputs: vm_name: description: The name of the virtual machine required: true resource_group_name: description: The name of the resource group to create or use for the virtual machine required: true location: description: The location where the virtual machine will be created required: true vm_size: description: The size of the virtual machine required: true env: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} jobs: create_vm: name: Create VM runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/[email protected] - name: Set up Azure CLI uses: azure/[email protected] with: azure-cli-version: latest - name: Login to Azure uses: azure/[email protected] with: credentials: ${{ env.AZURE_CREDENTIALS }} - name: Create Resource Group run: | az group create --name ${{ inputs.resource_group_name }} --location ${{ inputs.location }} - name: Create VM run: | az vm create --resource-group ${{ inputs.resource_group_name }} --name ${{ inputs.vm_name }} --location ${{ inputs.location }} --size ${{ inputs.vm_size }} --image UbuntuLTS --generate-ssh-keys
5. I want Azure CLI in this workflow can be authenticated by Service Principal instead, so I asked again
let’s make azure cli logged in with client id, client secret, azure subscription and tenant id
5th response
name: Create Azure VM on: workflow_dispatch: inputs: vm_name: description: The name of the virtual machine required: true resource_group_name: description: The name of the resource group to create or use for the virtual machine required: true location: description: The location where the virtual machine will be created required: true vm_size: description: The size of the virtual machine required: true client_id: description: The Azure AD Application ID required: true client_secret: description: The Azure AD Application secret required: true azure_subscription: description: The Azure subscription ID required: true tenant_id: description: The Azure AD Tenant ID required: true env: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} jobs: create_vm: name: Create VM runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/[email protected] - name: Set up Azure CLI uses: azure/[email protected] with: azure-cli-version: latest - name: Login to Azure run: | az login --service-principal -u ${{ inputs.client_id }} -p ${{ inputs.client_secret }} --tenant ${{ inputs.tenant_id }} az account set --subscription ${{ inputs.azure_subscription }} - name: Create Resource Group run: | az group create --name ${{ inputs.resource_group_name }} --location ${{ inputs.location }} - name: Create VM run: | az vm create --resource-group ${{ inputs.resource_group_name }} --name ${{ inputs.vm_name }} --location ${{ inputs.location }} --size ${{ inputs.vm_size }} --image UbuntuLTS --generate-ssh-keys
6. Hmm, I want Service Principal credential to be stored in Github secrets by
move client_id, client_secret, subscription_id, tenant_id to github secrets
Perfect response
name: Create Azure VM on: workflow_dispatch: inputs: vm_name: description: The name of the virtual machine required: true resource_group_name: description: The name of the resource group to create or use for the virtual machine required: true location: description: The location where the virtual machine will be created required: true vm_size: description: The size of the virtual machine required: true env: AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} jobs: create_vm: name: Create VM runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/[email protected] - name: Set up Azure CLI uses: azure/[email protected] with: azure-cli-version: latest - name: Login to Azure run: | az login --service-principal -u ${{ env.AZURE_CLIENT_ID }} -p ${{ env.AZURE_CLIENT_SECRET }} --tenant ${{ env.AZURE_TENANT_ID }} az account set --subscription ${{ env.AZURE_SUBSCRIPTION_ID }} - name: Create Resource Group run: | az group create --name ${{ inputs.resource_group_name }} --location ${{ inputs.location }} - name: Create VM run: | az vm create --resource-group ${{ inputs.resource_group_name }} --name ${{ inputs.vm_name }} --location ${{ inputs.location }} --size ${{ inputs.vm_size }} --image UbuntuLTS --generate-ssh-keys
Conclusions
I don’t have much time verify those code but I am pretty sure it will works on Github workflow. You can now try using this on https://beta.openai.com
Leave a Reply