Last active
November 14, 2023 05:15
-
-
Save dezren39/2aa3ac08d58ee3347944ce9646916003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-StrictMode -Version Latest | |
$PSNativeCommandUseErrorActionPreference = $true | |
if ($PSNativeCommandUseErrorActionPreference) { | |
$ErrorActionPreference = "Stop" | |
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' | |
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' | |
$PSDefaultParameterValues['*:Encoding'] = 'utf8' | |
$utf8 = New-Object System.Text.UTF8Encoding($true) | |
[Console]::OutputEncoding = $utf8 | |
$OutputEncoding = $utf8 | |
} | |
# update prefix, run the script, if all looks good, uncomment the delete lines and rerun. | |
$prefix = 'fucking-aws-i-hate-terraform-*' | |
aws iam list-instance-profiles ` | |
| ConvertFrom-Json ` | |
| Select-Object -ExpandProperty InstanceProfiles ` | |
| Where-Object { $_.InstanceProfileName -like "$prefix" } ` | |
| ForEach-Object { | |
$_.InstanceProfileName | |
# aws iam delete-instance-profile --instance-profile-name $_.InstanceProfileName | |
} | |
aws ec2 describe-launch-templates ` | |
| ConvertFrom-Json ` | |
| Select-Object -ExpandProperty LaunchTemplates ` | |
| Where-Object { $_.LaunchTemplateName -like "$prefix" } ` | |
| ForEach-Object { | |
$_.LaunchTemplateName | |
# aws ec2 delete-launch-template --launch-template-id $_.LaunchTemplateId | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment