$targetResource = @('ec2','rds')
$results = New-Object System.Collections.ArrayList
$targetResource | ForEach-Object {
$resouces = aws resourcegroupstaggingapi get-resources --resource-type-filter $_
$resouces = $resouces | ConvertFrom-Json
$resouces.ResourceTagMappingList | ForEach-Object {
$tagCheck = $false
$_.Tags | ForEach-Object {
if($_.Key -eq "CostDivision") {
$tagCheck = $true
}
}
if($tagCheck -eq $false) {
$result = New-Object psobject | Select-Object ResourceARN , Tags
$result.ResourceARN = $_.ResourceARN
$result.Tags = $_.Tags
[void]$results.Add($result)
}
}
}
$results
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme