Skip to content

Instantly share code, notes, and snippets.

@jincod
Last active April 26, 2018 18:23
Show Gist options
  • Save jincod/e9f8eef89a5332017edc9492493dbbf3 to your computer and use it in GitHub Desktop.
Save jincod/e9f8eef89a5332017edc9492493dbbf3 to your computer and use it in GitHub Desktop.
Powershell script: Delete all log groups from AWS CloudWatch
aws logs describe-log-groups --query logGroups --output json | ConvertFrom-Json |
ForEach-Object {$_.logGroupName} | ForEach-Object { aws logs delete-log-group --log-group-name $_ }
@MrRobertBooth
Copy link

I love the short scripts and have been trying to get the "default.ps1" Delete all AWS log groups to work; however, I get an error "ConvertFrom-Json : Invalid JSON primitive:" and not sure what is causing it. The command works in the sense that I can pull the logs groups using the "aws logs describe-log-groups --query logGroups" if I pull the ConvertFrom-Json off. Any ideas?

@jincod
Copy link
Author

jincod commented Nov 22, 2017

Hi @RobertboothVentech

Sorry for the late answer. I didn't get any notifications.

I missed --output json options for all aws cli calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment