Skip to content

Commit

Permalink
Removing hard-coded "rollback-on-failure" for stack creation
Browse files Browse the repository at this point in the history
Introduced new parameter to allow overriding to the default behavior
which is backwards compatible.  Useful in debugging a CFN template when
you want to preserve a failed stack creation for post-mortem analysis.
  • Loading branch information
ebekker committed May 4, 2016
1 parent 45fb9c2 commit 064e788
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions AwsCfn/CfnTemplateTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ A string format expression that is used to derive a unique Temporary URL S3 Key.

[Parameter(Mandatory=$false)]
[switch]$DeleteRollback,
[Parameter(Mandatory=$false)]
[Amazon.CloudFormation.OnFailure]$OnCreateFailure='ROLLBACK',

[Parameter(Mandatory=$false)]
[switch]$WhatIf,
Expand Down Expand Up @@ -211,6 +213,9 @@ A string format expression that is used to derive a unique Temporary URL S3 Key.
$cfnStackParams = @{
StackName = $StackName
}
$cfnCreateStackParams = @{
OnFailure = $OnCreateFailure
}
if ($TemplateUrl) {
$cfnStackParams.TemplateURL = $TemplateUrl
}
Expand Down Expand Up @@ -262,7 +267,7 @@ A string format expression that is used to derive a unique Temporary URL S3 Key.
else {
Write-Verbose "Creating NEW stack [$($StackName)]"
if (-not $WhatIf) {
New-CFNStack @cfnStackParams -OnFailure ROLLBACK @awsBaseParams
New-CFNStack @cfnCreateStackParams @cfnStackParams @awsBaseParams
}
}
}
Expand Down Expand Up @@ -387,6 +392,8 @@ Apply-CfnTemplate
[switch]$SkipChangeSet,
[Parameter(ParameterSetName="Apply")]
[switch]$DeleteRollback,
[Parameter(ParameterSetName="Apply")]
[Amazon.CloudFormation.OnFailure]$OnCreateFailure,

[string]$ProfileName,
[string]$Region
Expand Down Expand Up @@ -518,10 +525,11 @@ Apply-CfnTemplate

## Various "Apply" settings that may be specified
$applyParams = @{
TemplateBody = $tBodyJson
StackName = $StackName
ChangeSet = (-not $SkipChangeSet)
DeleteRollback = $DeleteRollback.IsPresent
TemplateBody = $tBodyJson
StackName = $StackName
ChangeSet = (-not $SkipChangeSet)
DeleteRollback = $DeleteRollback.IsPresent
OnCreateFailure = $OnCreateFailure
}
if ($stackDefaults.TempUrlBucket) { $applyParams.TempUrlBucket = $stackDefaults.TempUrlBucket }
if ($stackDefaults.TempUrlFmtStr) { $applyParams.TempUrlFmtStr = $stackDefaults.TempUrlFmtStr }
Expand Down

0 comments on commit 064e788

Please sign in to comment.