AWS Codebuild - List all projects and output into a file.

zekesebulino

Zeke Sebulino

Posted on March 6, 2023

AWS Codebuild - List all projects and output into a file.

Hey there! So, I recently had to tackle the challenge of identifying all of our AWS CodeBuilds that were using soon-to-be-deprecated Linux images. Given the large number of builds in our project, manually sifting through each one would have taken forever.

To save time, I turned to the AWS CLI and crafted a command that would help me list out all of our CodeBuilds alongside their corresponding Linux images. This way, I could quickly identify the builds that needed updating.

Here's the command I used:

aws codebuild list-projects | jq '.projects[]' | xargs -I{} sh -c 'aws codebuild batch-get-projects --names "$1" | jq -r "\"\(.projects[].name) : \(.projects[].environment.image)\"" ' _ {} >> list.txt

Enter fullscreen mode Exit fullscreen mode

It's a bit of a mouthful, but essentially what it does is use the list-projects command to fetch all CodeBuild projects, pipe them to jq to extract the project names, and then use xargs to pass each project name to the batch-get-projects command, which fetches the full project details including the Linux image. Finally, I used jq again to format the output as "project name : Linux image", and wrote the results to a file called list.txt.

Hope this helps you save some time too!

💖 💪 🙅 🚩
zekesebulino
Zeke Sebulino

Posted on March 6, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024

Modern C++ for LeetCode 🧑‍💻🚀
leetcode Modern C++ for LeetCode 🧑‍💻🚀

November 29, 2024