< Back

Get-PSCFNStackOutputs

Sun Jan 19, 2020 6:24 pm

NAME Get-PSCFNStackOutputs



SYNOPSIS

Get the outputs of a stack in various formats





SYNTAX

Get-PSCFNStackOutputs [-StackName] <String[]> [-AsHashtable] [<CommonParameters>]



Get-PSCFNStackOutputs [-StackName] <String[]> [-AsMappingBlock] [<CommonParameters>]



Get-PSCFNStackOutputs [-StackName] <String[]> [-AsParameterBlock] [<CommonParameters>]



Get-PSCFNStackOutputs [-StackName] <String[]> [-AsCrossStackReferences] [<CommonParameters>]





DESCRIPTION

This function can be used to assist creation of new CloudFormation templates

that refer to the outputs of another stack.



It can be used to generate either mapping or prarameter blocks based on these outputs

by converting the returned object to JSON or YAML





PARAMETERS

-StackName <String[]>

One or more stacks to process. One object is produced for each stack



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-AsHashtable [<SwitchParameter>]

If set (default), returned object is a hashtable - key/value pairs for each stack output.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-AsMappingBlock [<SwitchParameter>]

If set (default), returned object is formatted as a CloudFomration mapping block.

Converting the output to JSON or YAML renders text that can be pasted within a Mappings declararion.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-AsParameterBlock [<SwitchParameter>]

If set, returned object is formatted as a CloudFormation parameter block.

Converting the output to JSON or YAML renders text that can be pasted within a Parameters declararion.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-AsCrossStackReferences [<SwitchParameter>]

If set, returned object is formatted as a set of Fn::ImportValue statements, with any text matching the

stack name within the output's ExportName being replaced with a placeholder generated from the stack name with

the word 'Stack' appended.

Make this a parameter to your new stack.



Whilst the result converted to JSON is not much use as it is, the individual elements can

be copied and pasted in where an Fn::ImportValue for that parameter would be used.



YAML is not currently supported for this operation.



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 stack names or ARNs to this function





OUTPUTS

[PSObject] - An object dependent on the setting of the above switches. Pipe the output to ConvertTo-Json or

ConvertTo-Yaml





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



PS C:\\>Get-PSCFNStackOutputs -StackName MyStack -AsMappingBlock



When converted to JSON or YAML, can be pasted into the Mapping declaration of another template









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



PS C:\\>Get-PSCFNStackOutputs -StackName MyStack -AsParameterBlock



When converted to JSON or YAML, can be pasted into the Parameters declaration of another template









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



PS C:\\>Get-PSCFNStackOutputs -StackName MyStack -AsCrossStackReferences



When converted to JSON or YAML, provides a collection of Fn::Import stanzas that can be individually pasted into a

new template









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



PS C:\\>$hash = Get-PSCFNStackOutputs -StackName MyStack -AsHashtable



Returns hashtable of output key vs output value











RELATED LINKS