DEV Community

Zeke Sebulino
Zeke Sebulino

Posted on

1

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!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay