< Back

Remove-PSCFNStack

Sun Jan 19, 2020 6:25 pm

NAME Remove-PSCFNStack



SYNOPSIS

Delete one or more stacks.





SYNTAX

Remove-PSCFNStack [-StackName] <String[]> [-Wait] [-Sequential] [-Force] [-ThrowOnAbort] [-BackupTemplate]

[<CommonParameters>]





DESCRIPTION

Delete one or more stacks.

If -Wait is specified, stack events are output to the console including events from any nested stacks.



Deletion of multiple stacks can be either sequential or parallel.

If deleting a gruop of stacks where there are dependencies between them

use the -Sequential switch and list the stacks in dependency order.





PARAMETERS

-StackName <String[]>

Either stack names or the object returned by Get-CFNStack, New-CFNStack, Update-CFNStack

and other functions in this module when run with -Wait.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Wait [<SwitchParameter>]

If set and -Sequential is not set (so deleting in parallel), wait for all stacks to be deleted before

returning.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Sequential [<SwitchParameter>]

If set, delete stacks in the order they are specified on the command line or received from the pipeline,

waiting for each stack to delete successfully before proceeding to the next one.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Force [<SwitchParameter>]

If set, do not ask first.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-ThrowOnAbort [<SwitchParameter>]

If set, and user answers no when asked if stack should be deleted, throw an exception instead of just warning.

This switch is primarily for use by Reset-PSCFNStack to enable cancellation of the reset process.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-BackupTemplate [<SwitchParameter>]

If set, back up the current version of the template stored by CloudFormation, along with the current parameter

set if any to files in the current directory. This will assist with undoing any unwanted change.

Note that if you have dropped or replaced a database or anything else associcated with stored data, then the

data is lost forever!



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String[]

You can pipe the names or ARNs of the stacks to delete to this function





OUTPUTS

System.String[]

ARN(s) of deleted stack(s) else nothing if the stack did not exist or no stacks were deleted.





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Remove-PSCFNStack -StackName MyStack



Deletes a single stack.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Remove-PSCFNStack -StackName MyStack -BackupTemplate



As per the first example, but with the previous version of the template and its current parameter set saved to

files in the current directory.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>'DependentStack', 'BaseStack' | Remove-PSCFNStack -Sequential



Deletes 'DependentStack', waits for completion, then deletes 'BaseStack'.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>'Stack1', 'Stack2' | Remove-PSCFNStack -Wait



Sets both stacks deleting in parallel, then waits for them both to complete.









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>'Stack1', 'Stack2' | Remove-PSCFNStack



Sets both stacks deleting in parallel, and returns immediately.

See the CloudFormation console to monitor progress.









-------------------------- EXAMPLE 6 --------------------------



PS C:\\>Get-CFNStack | Remove-PSCFNStack



You would NOT want to do this, just like you wouldn't do rm -rf / ! It is for illustration only.

Sets ALL stacks in the region deleting simultaneously, which would probably trash some stacks

and then others would fail due to dependent resources.











RELATED LINKS