From 7d4fa528be4a0d4048b79ea264c5266035418e35 Mon Sep 17 00:00:00 2001 From: Stuart Haycroft Date: Thu, 12 Feb 2026 08:37:08 +0000 Subject: [PATCH 1/3] UpdateReplace Policy does not support RetainExceptOnCreate - reverting --- VaporShell/Public/Primary Functions/New-VaporResource.ps1 | 2 +- ci/Convert-SpecToFunction.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VaporShell/Public/Primary Functions/New-VaporResource.ps1 b/VaporShell/Public/Primary Functions/New-VaporResource.ps1 index d2c0f2d0a..3d35d78bd 100644 --- a/VaporShell/Public/Primary Functions/New-VaporResource.ps1 +++ b/VaporShell/Public/Primary Functions/New-VaporResource.ps1 @@ -140,7 +140,7 @@ function New-VaporResource { [System.String] $DeletionPolicy, [parameter(Mandatory = $false)] - [ValidateSet("Delete","Retain","Snapshot","RetainExceptOnCreate")] + [ValidateSet("Delete","Retain","Snapshot")] [System.String] $UpdateReplacePolicy, [parameter(Mandatory = $false,Position = 5)] diff --git a/ci/Convert-SpecToFunction.ps1 b/ci/Convert-SpecToFunction.ps1 index 1a8c12069..394215976 100644 --- a/ci/Convert-SpecToFunction.ps1 +++ b/ci/Convert-SpecToFunction.ps1 @@ -134,7 +134,7 @@ function $FunctionName { UpdateReplacePolicy differs from the DeletionPolicy attribute in that it only applies to resources replaced during stack updates. Use DeletionPolicy for resources deleted when a stack is deleted, or when the resource definition itself is deleted from the template as part of a stack update. - You must use one of the following options: "Delete","Retain","Snapshot","RetainExceptOnCreate"`n + You must use one of the following options: "Delete","Retain","Snapshot"`n "@ } @@ -408,7 +408,7 @@ function $FunctionName { if ($addCommonCfnProperty['UpdateReplacePolicy']) { $scriptContents += @" - [ValidateSet("Delete","Retain","Snapshot","RetainExceptOnCreate")] + [ValidateSet("Delete","Retain","Snapshot")] [System.String] `$UpdateReplacePolicy,`n "@ From 4b1b607ec74b48bfb8d719ff210fdfcc1ab4058d Mon Sep 17 00:00:00 2001 From: Stuart Haycroft Date: Fri, 6 Mar 2026 15:24:04 +0200 Subject: [PATCH 2/3] Adds missing intrinsic functions --- .../Intrinsic Functions/Add-FnLength.ps1 | 50 +++++++++++++++++++ .../Add-FnToJsonString.ps1 | 38 ++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 VaporShell/Public/Intrinsic Functions/Add-FnLength.ps1 create mode 100644 VaporShell/Public/Intrinsic Functions/Add-FnToJsonString.ps1 diff --git a/VaporShell/Public/Intrinsic Functions/Add-FnLength.ps1 b/VaporShell/Public/Intrinsic Functions/Add-FnLength.ps1 new file mode 100644 index 000000000..6ba5a76b7 --- /dev/null +++ b/VaporShell/Public/Intrinsic Functions/Add-FnLength.ps1 @@ -0,0 +1,50 @@ +function Add-FnLength { + <# + .SYNOPSIS + Adds the intrinsic function "Fn::Length" to a resource property + + .DESCRIPTION + The intrinsic function Fn::Length returns the number of elements within an array or the number of characters in a string. + + .LINK + https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-length.html + + .PARAMETER Object + The array or string for which you want to get the length. + + .EXAMPLE + Add-FnLength -Object (Add-FnSplit -Delimiter "," -SourceString "a,b,c") + + When the template is exported, this will convert to: {"Fn::Length":{"Fn::Split":[",","a,b,c"]}} + + .NOTES + You can use the following functions in the Fn::Length function: + Fn::Split + Fn::GetAZs + Ref + + .FUNCTIONALITY + Vaporshell + #> + [OutputType('Vaporshell.Function.Length')] + [cmdletbinding()] + Param + ( + [parameter(Mandatory = $true,Position = 0)] + [ValidateScript({ + $allowedTypes = "Vaporshell.Function.Split","Vaporshell.Function.GetAZs","Vaporshell.Function.Ref","System.String","System.Object[]" + if ([string]$($_.PSTypeNames) -match "($(($allowedTypes|ForEach-Object{[RegEx]::Escape($_)}) -join '|'))") { + $true + } + else { + $PSCmdlet.ThrowTerminatingError((New-VSError -String "This parameter only accepts the following types: $($allowedTypes -join ", "). The current types of the value are: $($_.PSTypeNames -join ", ").")) + } + })] + $Object + ) + $obj = [PSCustomObject][Ordered]@{ + "Fn::Length" = $Object + } + $obj | Add-ObjectDetail -TypeName 'Vaporshell.Function','Vaporshell.Function.Length' + Write-Verbose "Resulting JSON from $($MyInvocation.MyCommand): `n`n`t$($obj | ConvertTo-Json -Depth 10 -Compress)`n" +} diff --git a/VaporShell/Public/Intrinsic Functions/Add-FnToJsonString.ps1 b/VaporShell/Public/Intrinsic Functions/Add-FnToJsonString.ps1 new file mode 100644 index 000000000..866be9aba --- /dev/null +++ b/VaporShell/Public/Intrinsic Functions/Add-FnToJsonString.ps1 @@ -0,0 +1,38 @@ +function Add-FnToJsonString { + <# + .SYNOPSIS + Adds the intrinsic function "Fn::ToJsonString" to a resource property + + .DESCRIPTION + The intrinsic function Fn::ToJsonString converts an object or array to its corresponding JSON string. + + .LINK + https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ToJsonString.html + + .PARAMETER Object + The object or array to convert to a JSON string. + + .EXAMPLE + Add-FnToJsonString -Object @{key1 = "value1"; key2 = "value2"} + + When the template is exported, this will convert to: {"Fn::ToJsonString":{"key1":"value1","key2":"value2"}} + + .NOTES + You can use any intrinsic function within Fn::ToJsonString. + + .FUNCTIONALITY + Vaporshell + #> + [OutputType('Vaporshell.Function.ToJsonString')] + [cmdletbinding()] + Param + ( + [parameter(Mandatory = $true,Position = 0)] + $Object + ) + $obj = [PSCustomObject][Ordered]@{ + "Fn::ToJsonString" = $Object + } + $obj | Add-ObjectDetail -TypeName 'Vaporshell.Function','Vaporshell.Function.ToJsonString' + Write-Verbose "Resulting JSON from $($MyInvocation.MyCommand): `n`n`t$($obj | ConvertTo-Json -Depth 10 -Compress)`n" +} From 89766d6dccf9251d789911665cf4c309141b5ad0 Mon Sep 17 00:00:00 2001 From: Stuart Haycroft Date: Fri, 6 Mar 2026 15:44:11 +0200 Subject: [PATCH 3/3] changes version --- VaporShell/VaporShell.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VaporShell/VaporShell.psd1 b/VaporShell/VaporShell.psd1 index 5ba5c3e24..1152fc4d9 100644 --- a/VaporShell/VaporShell.psd1 +++ b/VaporShell/VaporShell.psd1 @@ -14,7 +14,7 @@ # Version number of this module. # NB do not change this in ECP when rebuilding only without making manual code changes in the repository. # Date will be appended to the PS module version automatically as part of the build process - ModuleVersion = '2.16.0' + ModuleVersion = '2.17.0' # ID used to uniquely identify this module GUID = 'd526494c-6e59-41ff-ad05-eedbc1473b6a'