Created
May 31, 2018 05:27
-
-
Save reecestart/8560d3232080dee3011457c59695de18 to your computer and use it in GitHub Desktop.
Checks all ASG's to see if they were created with a Service Linked Role and if not, lists username of who created the ASG
This file contains hidden or 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
cls | |
$ASGs = Get-ASAutoScalingGroup | |
$ASGsWithoutSLR = @() | |
foreach ($ASG in $ASGs) | |
{ | |
if ($ASG.ServiceLinkedRoleARN -eq $null) | |
{ | |
$ASGsWithoutSLR += $ASG | |
} | |
} | |
$CreateASGEvents = Find-CTEvent -LookupAttribute @{ AttributeKey="EventName"; AttributeValue="CreateAutoScalingGroup" } | |
$ASGsWithoutSLRsAndWhoCreatedThem = @() | |
foreach ($ASG in $ASGsWithoutSLR) | |
{ | |
$myobj = "" | Select "Username","ASG" | |
foreach ($CreateASGEvent in $CreateASGEvents) | |
{ | |
if ($CreateASGEvent.Resources.ResourceType -eq 'AWS::AutoScaling::AutoScalingGroup') | |
{ | |
if ($CreateASGEvent.Resources.ResourceName -eq $ASG.AutoScalingGroupName) | |
{ | |
$myobj.Username = $CreateASGEvent.Username | |
$myobj.ASG = $ASG.AutoScalingGroupName | |
} | |
} | |
} | |
$ASGsWithoutSLRsAndWhoCreatedThem += $myobj | |
$myobj = $null | |
} | |
Write-Host The following ASGs were created without an SLR and need to be recreated with an SLR -ForegroundColor Yellow | |
$ASGsWithoutSLRsAndWhoCreatedThem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment