From 23231856b7dd497c463249c87fba0ef40373402b Mon Sep 17 00:00:00 2001 From: Malhar Khimsaria <96malhar@gmail.com> Date: Wed, 24 Apr 2024 11:48:18 -0700 Subject: [PATCH 1/3] chore: Update User-Agent string in Lambda Tools for PS --- PowerShell/Module/AWSLambdaPSCore.psd1 | 2 +- PowerShell/Module/Private/_DeploymentFunctions.ps1 | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PowerShell/Module/AWSLambdaPSCore.psd1 b/PowerShell/Module/AWSLambdaPSCore.psd1 index 730cae731..639a2c3df 100644 --- a/PowerShell/Module/AWSLambdaPSCore.psd1 +++ b/PowerShell/Module/AWSLambdaPSCore.psd1 @@ -12,7 +12,7 @@ RootModule = 'AWSLambdaPSCore.psm1' # Version number of this module. -ModuleVersion = '4.0.0.0' +ModuleVersion = '4.0.1.0' # Supported PSEditions CompatiblePSEditions = 'Core' diff --git a/PowerShell/Module/Private/_DeploymentFunctions.ps1 b/PowerShell/Module/Private/_DeploymentFunctions.ps1 index c733e1e83..cdc1f19e0 100644 --- a/PowerShell/Module/Private/_DeploymentFunctions.ps1 +++ b/PowerShell/Module/Private/_DeploymentFunctions.ps1 @@ -194,7 +194,15 @@ function _deployProject $amazonLambdaToolsPath = _configureAmazonLambdaTools - $env:AWS_EXECUTION_ENV="AWSLambdaPSCore" + $moduleVersion = "Unknown" + $module = $MyInvocation.MyCommand.Module + if ($module) { + $moduleVersion = $module.Version.ToString() + } + # The leading whitespace is intentional + $userAgent = " lib/AWSLambdaPSCore#$moduleVersion" + + $env:AWS_EXECUTION_ENV=$userAgent try { if ($DisableInteractive) From 1e2ef70b02d0abd1d8cfb00e21b3baac94ca648b Mon Sep 17 00:00:00 2001 From: Malhar Khimsaria <96malhar@gmail.com> Date: Wed, 24 Apr 2024 15:27:31 -0700 Subject: [PATCH 2/3] Preserve existing environment variable value --- PowerShell/Module/Private/_DeploymentFunctions.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PowerShell/Module/Private/_DeploymentFunctions.ps1 b/PowerShell/Module/Private/_DeploymentFunctions.ps1 index cdc1f19e0..1852f9995 100644 --- a/PowerShell/Module/Private/_DeploymentFunctions.ps1 +++ b/PowerShell/Module/Private/_DeploymentFunctions.ps1 @@ -199,10 +199,14 @@ function _deployProject if ($module) { $moduleVersion = $module.Version.ToString() } - # The leading whitespace is intentional - $userAgent = " lib/AWSLambdaPSCore#$moduleVersion" + + $userAgent = "AWSLambdaPSCore lib/AWSLambdaPSCore#$moduleVersion" + if ($env:AWS_EXECUTION_ENV) { + $env:AWS_EXECUTION_ENV += " $userAgent" + } else { + $env:AWS_EXECUTION_ENV = $userAgent + } - $env:AWS_EXECUTION_ENV=$userAgent try { if ($DisableInteractive) From 5ac90c7468e34b8c0cca8272fde027bb8d6cd627 Mon Sep 17 00:00:00 2001 From: Malhar Khimsaria <96malhar@gmail.com> Date: Wed, 24 Apr 2024 16:05:17 -0700 Subject: [PATCH 3/3] Conditionally add AWSLambdaPSCore prefix --- PowerShell/Module/Private/_DeploymentFunctions.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell/Module/Private/_DeploymentFunctions.ps1 b/PowerShell/Module/Private/_DeploymentFunctions.ps1 index 1852f9995..8fff0854f 100644 --- a/PowerShell/Module/Private/_DeploymentFunctions.ps1 +++ b/PowerShell/Module/Private/_DeploymentFunctions.ps1 @@ -200,11 +200,11 @@ function _deployProject $moduleVersion = $module.Version.ToString() } - $userAgent = "AWSLambdaPSCore lib/AWSLambdaPSCore#$moduleVersion" + $userAgent = "lib/AWSLambdaPSCore#$moduleVersion" if ($env:AWS_EXECUTION_ENV) { $env:AWS_EXECUTION_ENV += " $userAgent" - } else { - $env:AWS_EXECUTION_ENV = $userAgent + } else { + $env:AWS_EXECUTION_ENV = "AWSLambdaPSCore $userAgent" } try