DEV Community

Cover image for Amazon Q: Assisting with My Monthly Maintenance
Bervianto Leo Pratama
Bervianto Leo Pratama

Posted on

Amazon Q: Assisting with My Monthly Maintenance

This is a submission for the Amazon Q Developer "Quack The Code" Challenge: Crushing the Command Line

What I Built

Each month, I had various devices that were not prepared to update the scripts for updating the applications and systems. Searching for the appropriate commands may take time. I remembered the tasks that I should do, but unfortunately forgot the scripts or commands. Let's ask Amazon Q for help to prepare the scripts.

Demo

Using Amazon Q Chat

First Task

Updating essential apps, for example, AWS CLI.

  • First Simple Prompt

Ask a simple script

  • First Simple Prompt Verification

Run the script

Second Task

Cleaning caches

  • Second Simple Prompt

Prompt Cache Cleaning

  • Second Simple Prompt Verification

Second Verification

Third Task

Back up the scripts into a directory and/or a repository.

  • Moving the scripts

Moving scripts

  • Adding the context and creating a README

Add context and create a readme

Well, I can also create the repository on GitHub without leaving the chat! Awesome!

Example prompt:

Create the repository in GitHub using the GitHub CLI
Enter fullscreen mode Exit fullscreen mode

Note:

  • I've set up the CLI before. So it will be done seamlessly.

Code Repository

System Maintenance Scripts

This directory contains scripts for various system maintenance tasks, primarily focused on package manager cache cleanup and AWS CLI updates.

Available Scripts

Package Manager Cache Cleanup

Script: clear-package-caches.sh

This script cleans the caches for multiple package managers:

  • npm: Clears the npm cache using npm cache clean --force
  • apt: Cleans the apt cache using sudo apt-get clean
  • NuGet: Clears NuGet caches using either nuget locals all -clear or dotnet nuget locals all --clear
  • pip: Purges the pip cache using pip cache purge or pip3 cache purge

The script checks for the presence of each package manager before attempting to clear its cache, so it's safe to run even if some package managers aren't installed.

Usage:

./clear-package-caches.sh
Enter fullscreen mode Exit fullscreen mode

AWS CLI Update Scripts

AWS CLI Version 2 Update

Script: update-aws-cli-v2.sh

Updates AWS CLI version 2 (recommended version) by:

  1. Downloading the latest installer from AWS
  2. Extracting and running the update process
  3. Cleaning…




How I Used Amazon Q Developer

I write a concise prompt for my recurring tasks. Detailed usage, explained in each section of the Demo.

Tips:

  • Write the prompt as concisely as you can.
  • Adding context will be helpful.

Top comments (0)