Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Release 2026-05-20

### AWSLambdaPSCore PowerShell Module (5.0.2)
* Reduce Lambda cold start INIT times by stripping files that are not used at runtime (PowerShell help XML and .pdb debug symbols) from AWS-authored modules (AWSPowerShell.NetCore and AWS.Tools.*) during packaging

## Release 2026-05-18

### Amazon.Lambda.Core (3.1.0)
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/Module/AWSLambdaPSCore.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AWSLambdaPSCore.psm1'

# Version number of this module.
ModuleVersion = '5.0.1.0'
ModuleVersion = '5.0.2.0'

# Supported PSEditions
CompatiblePSEditions = 'Core'
Expand Down
29 changes: 29 additions & 0 deletions PowerShell/Module/Private/_Constants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,33 @@ if (!($AwsPowerShellTargetFramework))
if (!($AwsPowerShellLambdaRuntime))
{
New-Variable -Name AwsPowerShellLambdaRuntime -Value 'dotnet10' -Option Constant
}

if (!($AwsModuleStripFilters))
{
# File patterns inside AWS-authored PowerShell modules that have no purpose at
# Lambda runtime (no interactive shell, no Get-Help, no debugger). Stripping
# them reduces package size and INIT (cold-start) duration. LICENSE / NOTICE
# files are intentionally retained.
#
# The '*.xml' pattern matches case-insensitively, covering:
# - <Module>.dll-Help.xml — PowerShell MAML help
# - <Module>.XML — .NET XMLDoc compiler output (IntelliSense data)
# - PSGetModuleInfo.xml — PowerShellGet install metadata
# Format.ps1xml / Types.ps1xml are NOT matched because their extension is
# .ps1xml (not .xml) and the wildcard requires a literal '.xml' suffix.
New-Variable -Name AwsModuleStripFilters -Value @(
'*.xml',
'*.pdb'
) -Option Constant
}

if (!($AwsAuthoredModuleNamePatterns))
{
# Only AWS-authored modules under Modules/ are stripped; third-party / community
# modules are left untouched.
New-Variable -Name AwsAuthoredModuleNamePatterns -Value @(
'AWSPowerShell.NetCore',
'AWS.Tools.*'
) -Option Constant
}
56 changes: 56 additions & 0 deletions PowerShell/Module/Private/_DeploymentFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,57 @@ function _formatArray
return $sb.ToString()
}

function _stripAwsModuleFiles
{
param
(
[Parameter(Mandatory = $true)]
[string]$ModulesRoot,

[Parameter(Mandatory = $true)]
[string[]]$Filters,

[Parameter(Mandatory = $true)]
[string[]]$ModuleNamePatterns
)

if (!(Test-Path -Path $ModulesRoot))
{
return
}

foreach ($moduleDir in (Get-ChildItem -Path $ModulesRoot -Directory))
{
$matchesAws = $false
foreach ($pattern in $ModuleNamePatterns)
{
if ($moduleDir.Name -like $pattern)
{
$matchesAws = $true
break
}
}

if (-not $matchesAws)
{
continue
}

$removed = Get-ChildItem -Path $moduleDir.FullName -Recurse -File -Include $Filters -ErrorAction SilentlyContinue
foreach ($file in $removed)
{
Write-Verbose ('Removing AWS module file: {0}' -f $file.FullName)
Remove-Item -LiteralPath $file.FullName -Force -ErrorAction SilentlyContinue
}

$count = ($removed | Measure-Object).Count
if ($count -gt 0)
{
Write-Verbose ('Stripped {0} unwanted file(s) from AWS module {1}' -f $count, $moduleDir.Name)
}
}
}

function _prepareDependentPowerShellModules
{
param
Expand Down Expand Up @@ -567,6 +618,11 @@ function _prepareDependentPowerShellModules
}
## Add verbosity that no RequiredModules found
else {Write-Verbose "No RequiredModules found for script '$Script'"}

_stripAwsModuleFiles `
-ModulesRoot $SavedModulesDirectory `
-Filters $AwsModuleStripFilters `
-ModuleNamePatterns $AwsAuthoredModuleNamePatterns
Comment thread
sankettangade marked this conversation as resolved.
}

function _findLocalModule
Expand Down
48 changes: 25 additions & 23 deletions PowerShell/Tests/Get-AWSPowerShelLambdaTemplate.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@ Import-Module $moduleManifestPath
InModuleScope -ModuleName $module -ScriptBlock {
Describe -Name 'Get-AWSPowerShellLambdaTemplate' -Fixture {

function LoadFakeData
{
ConvertTo-Json -InputObject @{
manifestVersion = 1
blueprints = @(
@{
name = 'Basic'
description = 'Bare bones script'
content = @(
@{
source = 'basic.ps1.txt'
output = '{basename}.ps1'
filetype = 'lambdaFunction'
},
@{
source = 'readme.txt'
output = 'readme.txt'
}
)
}
)
BeforeAll {
function LoadFakeData
{
ConvertTo-Json -InputObject @{
manifestVersion = 1
blueprints = @(
@{
name = 'Basic'
description = 'Bare bones script'
content = @(
@{
source = 'basic.ps1.txt'
output = '{basename}.ps1'
filetype = 'lambdaFunction'
},
@{
source = 'readme.txt'
output = 'readme.txt'
}
)
}
)
}
}
Mock -CommandName '_getHostedBlueprintsContent' -MockWith {LoadFakeData}
Mock -CommandName '_getLocalBlueprintsContent' -MockWith {LoadFakeData}
}
Mock -CommandName '_getHostedBlueprintsContent' -MockWith {LoadFakeData}
Mock -CommandName '_getLocalBlueprintsContent' -MockWith {LoadFakeData}

Context -Name 'Online Templates' -Fixture {
It -Name 'Retrieves Blueprints from online sources by default' -Test {
Expand Down
Loading
Loading