-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from fireflycons/dev
- Loading branch information
Showing
15 changed files
with
1,439 additions
and
152 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function Get-StackEvents | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Recursively get stack events from parent and nested stacks | ||
.PARAMETER StackArn | ||
ARN(s) of stack(s) to get events for | ||
.OUTPUTS | ||
[Amazon.CloudFormation.Model.StackEvent[]] | ||
Array of stack failure events. | ||
#> | ||
param | ||
( | ||
[string[]]$StackArn, | ||
[hashtable]$CredentialArguments, | ||
[DateTime]$EventsAfter | ||
) | ||
|
||
$StackArn | | ||
Where-Object { | ||
$null -ne $_ | ||
} | | ||
ForEach-Object { | ||
|
||
Get-CFNStackEvent -StackName $_ @CredentialArguments | | ||
Where-Object { | ||
$_.Timestamp -gt $EventsAfter | ||
} | ||
|
||
Get-CFNStackResourceList -StackName $_ @CredentialArguments | | ||
Where-Object { | ||
$_.ResourceType -ieq 'AWS::CloudFormation::Stack' | ||
} | | ||
ForEach-Object { | ||
|
||
if ($_ -and $_.PhysicalResourceId) | ||
{ | ||
Get-StackEvents -StackArn $_.PhysicalResourceId -EventsAfter $EventsAfter -CredentialArguments $CredentialArguments | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function Wait-PSCFNStack | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Wait for a stack to do something, printing events along the way. | ||
.PARAMETER StackArn | ||
Stack(s) to wait on. | ||
.PARAMETER CredentialArguments | ||
Hash of common credetial and region arguments. | ||
.PARAMETER StartTime | ||
Time the stack update command was issued | ||
.OUTPUTS | ||
[bool] true if operation succeeded; else false | ||
#> | ||
param | ||
( | ||
[string[]]$StackArn, | ||
|
||
[hashtable]$CredentialArguments, | ||
|
||
[DateTime]$StartTime | ||
) | ||
|
||
$checkTime = $StartTime | ||
|
||
# Copy input array so as not to trash it. | ||
$arns = $StackArn | | ||
Foreach-Object { | ||
$_ | ||
} | ||
|
||
# States indicating any stack operation complete | ||
$completionStates = @( | ||
'CREATE_COMPLETE' | ||
'CREATE_FAILED' | ||
'DELETE_COMPLETE' | ||
'DELETE_FAILED' | ||
'ROLLBACK_COMPLETE' | ||
'ROLLBACK_FAILED' | ||
'UPDATE_COMPLETE' | ||
'UPDATE_ROLLBACK_COMPLETE' | ||
'UPDATE_ROLLBACK_FAILED' | ||
) | ||
|
||
$anyFailed = $false | ||
|
||
$writeHeaders = $true | ||
|
||
while (($arns | Measure-Object).Count -gt 0) | ||
{ | ||
Start-Sleep -Seconds 15 | ||
|
||
$stacks = $arns | | ||
Foreach-Object { | ||
|
||
Get-CFNStack -StackName $_ @CredentialArguments | ||
} | ||
|
||
$completedStackArns = $stacks | | ||
Where-Object { | ||
|
||
if ($_.StackStatus -ilike '*ROLLBACK*' -or $_.StackStatus -ilike '*FAILED*') | ||
{ | ||
$anyFailed = $true | ||
} | ||
|
||
$completionStates -icontains $_.StackStatus | ||
} | | ||
Select-Object -ExpandProperty StackId | ||
|
||
if ($completedStackArns) | ||
{ | ||
$arns = Compare-Object -ReferenceObject $arns -DifferenceObject $completedStackArns -PassThru | ||
} | ||
|
||
$ts = Write-StackEvents -StackArn $arns -EventsAfter $checkTime $CredentialArguments -WriteHeaders $writeHeaders | ||
$writeHeaders = $false | ||
|
||
if ($ts) | ||
{ | ||
$checkTime = $ts | ||
} | ||
} | ||
|
||
Write-StackEvents -StackArn $StackArn -EventsAfter $checkTime $CredentialArguments -WriteHeaders $false | ||
|
||
# Output boolean - any final state containing ROLLBACK or FAILED indicates operation unsuccessful | ||
-not $anyFailed | ||
} |
Oops, something went wrong.