aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.57k stars 478 forks source link

Lambda Powershell bootstrap issue when #Requires modules are loaded in publishing environment #622

Closed ghost closed 3 years ago

ghost commented 4 years ago

Something about:

...seems to break the ordering of module import during the bootstrap process, and the resultant function will not run.

Environment:

PS > $psversiontable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS > get-module | select name, version | sort name

Name                            Version
----                            -------
aws.tools.common                4.0.5.0
aws.tools.s3                    4.0.5.0
AWSLambdaPSCore                 2.0.0.0
ImportGuard                     0.0
Microsoft.PowerShell.Management 7.0.0.0
Microsoft.PowerShell.Utility    7.0.0.0
PSReadLine                      2.0.0

Failure Scenario:

pslambda_test.ps1 contents:

#Requires -Modules 'AWS.Tools.Common','AWS.Tools.S3'
write-host "This function started successfully"

Script to publish:

$PublishSettings = @{
  Name = "pslambda_test"
  ScriptPath = "./pslambda_test.ps1"
  Memory = 512
  Timeout = 20
  Region = 'us-east-2'
  IAMRoleArn = 'arn:aws:iam::012345678901:role/my_lambda_role_name'
  Verbose = $true
}

Import-Module 'aws.tools.common','aws.tools.s3'
Import-module 'AWSLambdaPSCore'

Publish-AWSPowerShellLambda @PublishSettings
Output of Publish-AWSPowerShellLambda -verbose:

```text WARNING: Multiple variants of AWS Tools for PowerShell (AWSPowerShell, AWSPowerShell.NetCore or AWS.Tools) are currently installed. Please run 'Get-Module -Name AWSPowerShell,AWSPowerShell.NetCore,AWS.Tools.Common -ListAvailable' for details. To avoid problems with cmdlet auto-importing, it is suggested to only install one variant. AWS.Tools is the new modularized version of AWS Tools for PowerShell, compatible with PowerShell Core 6+ and Windows Powershell 5.1+ (when .NET Framework 4.7.2+ is installed). AWSPowerShell.NetCore is the monolithic variant that supports all AWS services in a single large module, it is compatible with PowerShell Core 6+ and Windows Powershell 3+ (when .NET Framework 4.7.2+ is installed). AWSPowerShell is the legacy module for older systems which are either running Windows PowerShell 2 or cannot be updated to .NET Framework 4.7.2 (or newer). Staging deployment at C:\Users\ME\AppData\Local\Temp\pslambda_test Configuring PowerShell to version 7.0.0 Generating C# project C:\Users\ME\AppData\Local\Temp\pslambda_test\pslambda_test.csproj used to create Lambda function bundle. Generating C:\Users\ME\AppData\Local\Temp\pslambda_test\Bootstrap.cs to load PowerShell script and required modules in Lambda environment. Generating aws-lambda-tools-defaults.json config file with default values used when publishing project. Copying PowerShell script to staging directory VERBOSE: Found imported module aws.tools.common (4.0.5.0) to save with package bundle. Copying local module aws.tools.common(4.0.5.0) from C:\Users\ME\Documents\PowerShell\Modules\aws.tools.common\4.0.5.0 VERBOSE: Found imported module aws.tools.s3 (4.0.5.0) to save with package bundle. Copying local module aws.tools.s3(4.0.5.0) from C:\Users\ME\Documents\PowerShell\Modules\aws.tools.s3\4.0.5.0 Deploying to AWS Lambda Restoring .NET Lambda deployment tool VERBOSE: Installing .NET Global Tool Amazon.Lambda.Tools VERBOSE: Error installing, attempting to update Amazon.Lambda.Tools VERBOSE: Looking for windows excutable for dotnet-lambda.exe Initiate deployment Amazon Lambda Tools for .NET Core applications (4.0.0) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet Executing publish command ... invoking 'dotnet publish', working folder 'C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\publish' ... publish: Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core ... publish: Copyright (C) Microsoft Corporation. All rights reserved. ... publish: Restore completed in 1.13 sec for C:\Users\ME\AppData\Local\Temp\pslambda_test\pslambda_test.csproj. ... publish: pslambda_test -> C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\linux-x64\pslambda_test.dll ... publish: pslambda_test -> C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\publish\ Zipping publish folder C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\publish to C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\pslambda_test.zip ... zipping: Amazon.Lambda.Core.dll ... zipping: Amazon.Lambda.PowerShellHost.dll ... zipping: libmi.so ... zipping: libpsl-native.so ... zipping: libpsrpclient.so ... zipping: Markdig.Signed.dll ... zipping: Microsoft.ApplicationInsights.dll ... zipping: Microsoft.CodeAnalysis.CSharp.dll ... zipping: Microsoft.CodeAnalysis.dll ... zipping: Microsoft.Management.Infrastructure.dll ... zipping: Microsoft.PowerShell.Commands.Management.dll ... zipping: Microsoft.PowerShell.Commands.Utility.dll ... zipping: Microsoft.PowerShell.ConsoleHost.dll ... zipping: Microsoft.PowerShell.MarkdownRender.dll ... zipping: Microsoft.PowerShell.SDK.dll ... zipping: Microsoft.PowerShell.Security.dll ... zipping: Microsoft.Win32.Registry.AccessControl.dll ... zipping: Microsoft.Win32.SystemEvents.dll ... zipping: Namotion.Reflection.dll ... zipping: Newtonsoft.Json.dll ... zipping: NJsonSchema.dll ... zipping: pslambda_test.deps.json ... zipping: pslambda_test.dll ... zipping: pslambda_test.pdb ... zipping: pslambda_test.ps1 ... zipping: pslambda_test.runtimeconfig.json ... zipping: System.CodeDom.dll ... zipping: System.ComponentModel.Composition.dll ... zipping: System.ComponentModel.Composition.Registration.dll ... zipping: System.Configuration.ConfigurationManager.dll ... zipping: System.Data.Odbc.dll ... zipping: System.Data.OleDb.dll ... zipping: System.Data.SqlClient.dll ... zipping: System.Diagnostics.EventLog.dll ... zipping: System.Diagnostics.PerformanceCounter.dll ... zipping: System.DirectoryServices.AccountManagement.dll ... zipping: System.DirectoryServices.dll ... zipping: System.DirectoryServices.Protocols.dll ... zipping: System.Drawing.Common.dll ... zipping: System.IO.Packaging.dll ... zipping: System.IO.Ports.dll ... zipping: System.IO.Ports.Native.so ... zipping: System.Management.Automation.dll ... zipping: System.Management.dll ... zipping: System.Net.Http.WinHttpHandler.dll ... zipping: System.Private.ServiceModel.dll ... zipping: System.Reflection.Context.dll ... zipping: System.Runtime.Caching.dll ... zipping: System.Security.Cryptography.Pkcs.dll ... zipping: System.Security.Cryptography.ProtectedData.dll ... zipping: System.Security.Cryptography.Xml.dll ... zipping: System.Security.Permissions.dll ... zipping: System.ServiceModel.dll ... zipping: System.ServiceModel.Duplex.dll ... zipping: System.ServiceModel.Http.dll ... zipping: System.ServiceModel.NetTcp.dll ... zipping: System.ServiceModel.Primitives.dll ... zipping: System.ServiceModel.Security.dll ... zipping: System.ServiceModel.Syndication.dll ... zipping: System.ServiceProcess.ServiceController.dll ... zipping: System.Threading.AccessControl.dll ... zipping: System.Windows.Extensions.dll ... zipping: cs/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: cs/Microsoft.CodeAnalysis.resources.dll ... zipping: de/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: de/Microsoft.CodeAnalysis.resources.dll ... zipping: es/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: es/Microsoft.CodeAnalysis.resources.dll ... zipping: fr/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: fr/Microsoft.CodeAnalysis.resources.dll ... zipping: it/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: it/Microsoft.CodeAnalysis.resources.dll ... zipping: ja/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: ja/Microsoft.CodeAnalysis.resources.dll ... zipping: ko/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: ko/Microsoft.CodeAnalysis.resources.dll ... zipping: pl/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: pl/Microsoft.CodeAnalysis.resources.dll ... zipping: pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: pt-BR/Microsoft.CodeAnalysis.resources.dll ... zipping: ref/Microsoft.CSharp.dll ... zipping: ref/Microsoft.VisualBasic.Core.dll ... zipping: ref/Microsoft.VisualBasic.dll ... zipping: ref/Microsoft.Win32.Primitives.dll ... zipping: ref/mscorlib.dll ... zipping: ref/netstandard.dll ... zipping: ref/System.AppContext.dll ... zipping: ref/System.Buffers.dll ... zipping: ref/System.Collections.Concurrent.dll ... zipping: ref/System.Collections.dll ... zipping: ref/System.Collections.Immutable.dll ... zipping: ref/System.Collections.NonGeneric.dll ... zipping: ref/System.Collections.Specialized.dll ... zipping: ref/System.ComponentModel.Annotations.dll ... zipping: ref/System.ComponentModel.DataAnnotations.dll ... zipping: ref/System.ComponentModel.dll ... zipping: ref/System.ComponentModel.EventBasedAsync.dll ... zipping: ref/System.ComponentModel.Primitives.dll ... zipping: ref/System.ComponentModel.TypeConverter.dll ... zipping: ref/System.Configuration.dll ... zipping: ref/System.Console.dll ... zipping: ref/System.Core.dll ... zipping: ref/System.Data.Common.dll ... zipping: ref/System.Data.DataSetExtensions.dll ... zipping: ref/System.Data.dll ... zipping: ref/System.Diagnostics.Contracts.dll ... zipping: ref/System.Diagnostics.Debug.dll ... zipping: ref/System.Diagnostics.DiagnosticSource.dll ... zipping: ref/System.Diagnostics.FileVersionInfo.dll ... zipping: ref/System.Diagnostics.Process.dll ... zipping: ref/System.Diagnostics.StackTrace.dll ... zipping: ref/System.Diagnostics.TextWriterTraceListener.dll ... zipping: ref/System.Diagnostics.Tools.dll ... zipping: ref/System.Diagnostics.TraceSource.dll ... zipping: ref/System.Diagnostics.Tracing.dll ... zipping: ref/System.dll ... zipping: ref/System.Drawing.dll ... zipping: ref/System.Drawing.Primitives.dll ... zipping: ref/System.Dynamic.Runtime.dll ... zipping: ref/System.Globalization.Calendars.dll ... zipping: ref/System.Globalization.dll ... zipping: ref/System.Globalization.Extensions.dll ... zipping: ref/System.IO.Compression.Brotli.dll ... zipping: ref/System.IO.Compression.dll ... zipping: ref/System.IO.Compression.FileSystem.dll ... zipping: ref/System.IO.Compression.ZipFile.dll ... zipping: ref/System.IO.dll ... zipping: ref/System.IO.FileSystem.dll ... zipping: ref/System.IO.FileSystem.DriveInfo.dll ... zipping: ref/System.IO.FileSystem.Primitives.dll ... zipping: ref/System.IO.FileSystem.Watcher.dll ... zipping: ref/System.IO.IsolatedStorage.dll ... zipping: ref/System.IO.MemoryMappedFiles.dll ... zipping: ref/System.IO.Pipes.dll ... zipping: ref/System.IO.UnmanagedMemoryStream.dll ... zipping: ref/System.Linq.dll ... zipping: ref/System.Linq.Expressions.dll ... zipping: ref/System.Linq.Parallel.dll ... zipping: ref/System.Linq.Queryable.dll ... zipping: ref/System.Memory.dll ... zipping: ref/System.Net.dll ... zipping: ref/System.Net.Http.dll ... zipping: ref/System.Net.HttpListener.dll ... zipping: ref/System.Net.Mail.dll ... zipping: ref/System.Net.NameResolution.dll ... zipping: ref/System.Net.NetworkInformation.dll ... zipping: ref/System.Net.Ping.dll ... zipping: ref/System.Net.Primitives.dll ... zipping: ref/System.Net.Requests.dll ... zipping: ref/System.Net.Security.dll ... zipping: ref/System.Net.ServicePoint.dll ... zipping: ref/System.Net.Sockets.dll ... zipping: ref/System.Net.WebClient.dll ... zipping: ref/System.Net.WebHeaderCollection.dll ... zipping: ref/System.Net.WebProxy.dll ... zipping: ref/System.Net.WebSockets.Client.dll ... zipping: ref/System.Net.WebSockets.dll ... zipping: ref/System.Numerics.dll ... zipping: ref/System.Numerics.Vectors.dll ... zipping: ref/System.ObjectModel.dll ... zipping: ref/System.Reflection.DispatchProxy.dll ... zipping: ref/System.Reflection.dll ... zipping: ref/System.Reflection.Emit.dll ... zipping: ref/System.Reflection.Emit.ILGeneration.dll ... zipping: ref/System.Reflection.Emit.Lightweight.dll ... zipping: ref/System.Reflection.Extensions.dll ... zipping: ref/System.Reflection.Metadata.dll ... zipping: ref/System.Reflection.Primitives.dll ... zipping: ref/System.Reflection.TypeExtensions.dll ... zipping: ref/System.Resources.Reader.dll ... zipping: ref/System.Resources.ResourceManager.dll ... zipping: ref/System.Resources.Writer.dll ... zipping: ref/System.Runtime.CompilerServices.Unsafe.dll ... zipping: ref/System.Runtime.CompilerServices.VisualC.dll ... zipping: ref/System.Runtime.dll ... zipping: ref/System.Runtime.Extensions.dll ... zipping: ref/System.Runtime.Handles.dll ... zipping: ref/System.Runtime.InteropServices.dll ... zipping: ref/System.Runtime.InteropServices.RuntimeInformation.dll ... zipping: ref/System.Runtime.InteropServices.WindowsRuntime.dll ... zipping: ref/System.Runtime.Intrinsics.dll ... zipping: ref/System.Runtime.Loader.dll ... zipping: ref/System.Runtime.Numerics.dll ... zipping: ref/System.Runtime.Serialization.dll ... zipping: ref/System.Runtime.Serialization.Formatters.dll ... zipping: ref/System.Runtime.Serialization.Json.dll ... zipping: ref/System.Runtime.Serialization.Primitives.dll ... zipping: ref/System.Runtime.Serialization.Xml.dll ... zipping: ref/System.Security.Claims.dll ... zipping: ref/System.Security.Cryptography.Algorithms.dll ... zipping: ref/System.Security.Cryptography.Csp.dll ... zipping: ref/System.Security.Cryptography.Encoding.dll ... zipping: ref/System.Security.Cryptography.Primitives.dll ... zipping: ref/System.Security.Cryptography.X509Certificates.dll ... zipping: ref/System.Security.dll ... zipping: ref/System.Security.Principal.dll ... zipping: ref/System.Security.SecureString.dll ... zipping: ref/System.ServiceModel.Web.dll ... zipping: ref/System.ServiceProcess.dll ... zipping: ref/System.Text.Encoding.CodePages.dll ... zipping: ref/System.Text.Encoding.dll ... zipping: ref/System.Text.Encoding.Extensions.dll ... zipping: ref/System.Text.Encodings.Web.dll ... zipping: ref/System.Text.Json.dll ... zipping: ref/System.Text.RegularExpressions.dll ... zipping: ref/System.Threading.Channels.dll ... zipping: ref/System.Threading.dll ... zipping: ref/System.Threading.Overlapped.dll ... zipping: ref/System.Threading.Tasks.Dataflow.dll ... zipping: ref/System.Threading.Tasks.dll ... zipping: ref/System.Threading.Tasks.Extensions.dll ... zipping: ref/System.Threading.Tasks.Parallel.dll ... zipping: ref/System.Threading.Thread.dll ... zipping: ref/System.Threading.ThreadPool.dll ... zipping: ref/System.Threading.Timer.dll ... zipping: ref/System.Transactions.dll ... zipping: ref/System.Transactions.Local.dll ... zipping: ref/System.ValueTuple.dll ... zipping: ref/System.Web.dll ... zipping: ref/System.Web.HttpUtility.dll ... zipping: ref/System.Windows.dll ... zipping: ref/System.Xml.dll ... zipping: ref/System.Xml.Linq.dll ... zipping: ref/System.Xml.ReaderWriter.dll ... zipping: ref/System.Xml.Serialization.dll ... zipping: ref/System.Xml.XDocument.dll ... zipping: ref/System.Xml.XmlDocument.dll ... zipping: ref/System.Xml.XmlSerializer.dll ... zipping: ref/System.Xml.XPath.dll ... zipping: ref/System.Xml.XPath.XDocument.dll ... zipping: ref/WindowsBase.dll ... zipping: ru/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: ru/Microsoft.CodeAnalysis.resources.dll ... zipping: tr/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: tr/Microsoft.CodeAnalysis.resources.dll ... zipping: zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: zh-Hans/Microsoft.CodeAnalysis.resources.dll ... zipping: zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: zh-Hant/Microsoft.CodeAnalysis.resources.dll ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.Aliases.psm1 ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.Completers.psm1 ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.dll ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.dll-Help.xml ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.Format.ps1xml ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.psd1 ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.XML ... zipping: Modules/aws.tools.common/4.0.5.0/AWSSDK.Core.dll ... zipping: Modules/aws.tools.common/4.0.5.0/AWSSDK.SecurityToken.dll ... zipping: Modules/aws.tools.common/4.0.5.0/ImportGuard.ps1 ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.Aliases.psm1 ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.Completers.psm1 ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.dll ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.dll-Help.xml ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.Format.ps1xml ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.psd1 ... zipping: Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.XML ... zipping: Modules/aws.tools.s3/4.0.5.0/AWSSDK.S3.dll ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Host/Microsoft.PowerShell.Host.psd1 ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1 ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/CimCmdlets/CimCmdlets.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/Diagnostics.format.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/Event.format.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/GetEvent.types.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Host/Microsoft.PowerShell.Host.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.WSMan.Management/Microsoft.WSMan.Management.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.WSMan.Management/WSMan.format.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/PSDiagnostics/PSDiagnostics.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/PSDiagnostics/PSDiagnostics.psm1 Created publish archive (C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\pslambda_test.zip). Updating code for existing function pslambda_test VERBOSE: Removing staging directory C:\Users\ME\AppData\Local\Temp\pslambda_test ```

Output of an invocation:

``` START RequestId: 736935b3-01f3-44d2-9de0-37a5a8a186f0 Version: $LATEST Importing module ./Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.psd1 [Error] - The required module 'AWS.Tools.Common' is not loaded. Load the module or remove the module from 'RequiredModules' in the file '/var/task/Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.psd1'. Importing module ./Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.psd1 [Error] - The required module 'AWS.Tools.Common' is not loaded. Load the module or remove the module from 'RequiredModules' in the file '/var/task/Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.psd1'. An exception was thrown when the constructor for type 'pslambda_test.Bootstrap' was invoked. Check inner exception for more details.: LambdaException at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor) at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type) The required module 'AWS.Tools.Common' is not loaded. Load the module or remove the module from 'RequiredModules' in the file '/var/task/Modules/aws.tools.s3/4.0.5.0/AWS.Tools.S3.psd1'.: MissingMemberException at Amazon.Lambda.PowerShellHost.PowerShellFunctionHost..ctor() at Amazon.Lambda.PowerShellHost.PowerShellFunctionHost..ctor(String powerShellScriptFileName) at pslambda_test.Bootstrap..ctor() in C:\Users\ME\AppData\Local\Temp\pslambda_test\Bootstrap.cs:line 9 09 Apr 2020 17:40:35,494 [WARN] (invoke@invoke.c:297 errno: Address family not supported by protocol) run_dotnet(dotnet_path, &args) failed END RequestId: 736935b3-01f3-44d2-9de0-37a5a8a186f0 REPORT RequestId: 736935b3-01f3-44d2-9de0-37a5a8a186f0 Duration: 6756.47 ms Billed Duration: 6800 ms Memory Size: 512 MB Max Memory Used: 68 MB Unknown application error occurred ```

Workaround

If I start with a new, clean PS environment and don't Import-Module 'aws.tools.common','aws.tools.s3', the publish results in a working function.

One odd example to prevent this issue is to capitalize a single character, the "T" in aws.Tools.s3 in our publish script:

$PublishSettings = @{
  Name = "pslambda_test"
  ScriptPath = "./pslambda_test.ps1"
  Memory = 512
  Timeout = 20
  Region = 'us-east-2'
  IAMRoleArn = 'arn:aws:iam::012345678901:role/my_lambda_role_name'
  Verbose = $true
}

Import-Module 'aws.tools.common','aws.Tools.s3'
Import-module 'AWSLambdaPSCore'

Publish-AWSPowerShellLambda @PublishSettings
Output of Publish-AWSPowerShellLambda -verbose:

```text WARNING: Multiple variants of AWS Tools for PowerShell (AWSPowerShell, AWSPowerShell.NetCore or AWS.Tools) are currently installed. Please run 'Get-Module -Name AWSPowerShell,AWSPowerShell.NetCore,AWS.Tools.Common -ListAvailable' for details. To avoid problems with cmdlet auto-importing, it is suggested to only install one variant. AWS.Tools is the new modularized version of AWS Tools for PowerShell, compatible with PowerShell Core 6+ and Windows Powershell 5.1+ (when .NET Framework 4.7.2+ is installed). AWSPowerShell.NetCore is the monolithic variant that supports all AWS services in a single large module, it is compatible with PowerShell Core 6+ and Windows Powershell 3+ (when .NET Framework 4.7.2+ is installed). AWSPowerShell is the legacy module for older systems which are either running Windows PowerShell 2 or cannot be updated to .NET Framework 4.7.2 (or newer). Staging deployment at C:\Users\ME\AppData\Local\Temp\pslambda_test Configuring PowerShell to version 7.0.0 Generating C# project C:\Users\ME\AppData\Local\Temp\pslambda_test\pslambda_test.csproj used to create Lambda function bundle. Generating C:\Users\ME\AppData\Local\Temp\pslambda_test\Bootstrap.cs to load PowerShell script and required modules in Lambda environment. Generating aws-lambda-tools-defaults.json config file with default values used when publishing project. Copying PowerShell script to staging directory VERBOSE: Found imported module aws.tools.common (4.0.5.0) to save with package bundle. Copying local module aws.tools.common(4.0.5.0) from C:\Users\ME\Documents\PowerShell\Modules\aws.tools.common\4.0.5.0 VERBOSE: Found imported module aws.Tools.s3 (4.0.5.0) to save with package bundle. Copying local module aws.Tools.s3(4.0.5.0) from C:\Users\ME\Documents\PowerShell\Modules\aws.Tools.s3\4.0.5.0 Deploying to AWS Lambda Restoring .NET Lambda deployment tool VERBOSE: Installing .NET Global Tool Amazon.Lambda.Tools VERBOSE: Error installing, attempting to update Amazon.Lambda.Tools VERBOSE: Looking for windows excutable for dotnet-lambda.exe Initiate deployment Amazon Lambda Tools for .NET Core applications (4.0.0) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet Executing publish command ... invoking 'dotnet publish', working folder 'C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\publish' ... publish: Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core ... publish: Copyright (C) Microsoft Corporation. All rights reserved. ... publish: Restore completed in 1.2 sec for C:\Users\ME\AppData\Local\Temp\pslambda_test\pslambda_test.csproj. ... publish: pslambda_test -> C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\linux-x64\pslambda_test.dll ... publish: pslambda_test -> C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\publish\ Zipping publish folder C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\publish to C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\pslambda_test.zip ... zipping: Amazon.Lambda.Core.dll ... zipping: Amazon.Lambda.PowerShellHost.dll ... zipping: libmi.so ... zipping: libpsl-native.so ... zipping: libpsrpclient.so ... zipping: Markdig.Signed.dll ... zipping: Microsoft.ApplicationInsights.dll ... zipping: Microsoft.CodeAnalysis.CSharp.dll ... zipping: Microsoft.CodeAnalysis.dll ... zipping: Microsoft.Management.Infrastructure.dll ... zipping: Microsoft.PowerShell.Commands.Management.dll ... zipping: Microsoft.PowerShell.Commands.Utility.dll ... zipping: Microsoft.PowerShell.ConsoleHost.dll ... zipping: Microsoft.PowerShell.MarkdownRender.dll ... zipping: Microsoft.PowerShell.SDK.dll ... zipping: Microsoft.PowerShell.Security.dll ... zipping: Microsoft.Win32.Registry.AccessControl.dll ... zipping: Microsoft.Win32.SystemEvents.dll ... zipping: Namotion.Reflection.dll ... zipping: Newtonsoft.Json.dll ... zipping: NJsonSchema.dll ... zipping: pslambda_test.deps.json ... zipping: pslambda_test.dll ... zipping: pslambda_test.pdb ... zipping: pslambda_test.ps1 ... zipping: pslambda_test.runtimeconfig.json ... zipping: System.CodeDom.dll ... zipping: System.ComponentModel.Composition.dll ... zipping: System.ComponentModel.Composition.Registration.dll ... zipping: System.Configuration.ConfigurationManager.dll ... zipping: System.Data.Odbc.dll ... zipping: System.Data.OleDb.dll ... zipping: System.Data.SqlClient.dll ... zipping: System.Diagnostics.EventLog.dll ... zipping: System.Diagnostics.PerformanceCounter.dll ... zipping: System.DirectoryServices.AccountManagement.dll ... zipping: System.DirectoryServices.dll ... zipping: System.DirectoryServices.Protocols.dll ... zipping: System.Drawing.Common.dll ... zipping: System.IO.Packaging.dll ... zipping: System.IO.Ports.dll ... zipping: System.IO.Ports.Native.so ... zipping: System.Management.Automation.dll ... zipping: System.Management.dll ... zipping: System.Net.Http.WinHttpHandler.dll ... zipping: System.Private.ServiceModel.dll ... zipping: System.Reflection.Context.dll ... zipping: System.Runtime.Caching.dll ... zipping: System.Security.Cryptography.Pkcs.dll ... zipping: System.Security.Cryptography.ProtectedData.dll ... zipping: System.Security.Cryptography.Xml.dll ... zipping: System.Security.Permissions.dll ... zipping: System.ServiceModel.dll ... zipping: System.ServiceModel.Duplex.dll ... zipping: System.ServiceModel.Http.dll ... zipping: System.ServiceModel.NetTcp.dll ... zipping: System.ServiceModel.Primitives.dll ... zipping: System.ServiceModel.Security.dll ... zipping: System.ServiceModel.Syndication.dll ... zipping: System.ServiceProcess.ServiceController.dll ... zipping: System.Threading.AccessControl.dll ... zipping: System.Windows.Extensions.dll ... zipping: cs/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: cs/Microsoft.CodeAnalysis.resources.dll ... zipping: de/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: de/Microsoft.CodeAnalysis.resources.dll ... zipping: es/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: es/Microsoft.CodeAnalysis.resources.dll ... zipping: fr/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: fr/Microsoft.CodeAnalysis.resources.dll ... zipping: it/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: it/Microsoft.CodeAnalysis.resources.dll ... zipping: ja/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: ja/Microsoft.CodeAnalysis.resources.dll ... zipping: ko/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: ko/Microsoft.CodeAnalysis.resources.dll ... zipping: pl/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: pl/Microsoft.CodeAnalysis.resources.dll ... zipping: pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: pt-BR/Microsoft.CodeAnalysis.resources.dll ... zipping: ref/Microsoft.CSharp.dll ... zipping: ref/Microsoft.VisualBasic.Core.dll ... zipping: ref/Microsoft.VisualBasic.dll ... zipping: ref/Microsoft.Win32.Primitives.dll ... zipping: ref/mscorlib.dll ... zipping: ref/netstandard.dll ... zipping: ref/System.AppContext.dll ... zipping: ref/System.Buffers.dll ... zipping: ref/System.Collections.Concurrent.dll ... zipping: ref/System.Collections.dll ... zipping: ref/System.Collections.Immutable.dll ... zipping: ref/System.Collections.NonGeneric.dll ... zipping: ref/System.Collections.Specialized.dll ... zipping: ref/System.ComponentModel.Annotations.dll ... zipping: ref/System.ComponentModel.DataAnnotations.dll ... zipping: ref/System.ComponentModel.dll ... zipping: ref/System.ComponentModel.EventBasedAsync.dll ... zipping: ref/System.ComponentModel.Primitives.dll ... zipping: ref/System.ComponentModel.TypeConverter.dll ... zipping: ref/System.Configuration.dll ... zipping: ref/System.Console.dll ... zipping: ref/System.Core.dll ... zipping: ref/System.Data.Common.dll ... zipping: ref/System.Data.DataSetExtensions.dll ... zipping: ref/System.Data.dll ... zipping: ref/System.Diagnostics.Contracts.dll ... zipping: ref/System.Diagnostics.Debug.dll ... zipping: ref/System.Diagnostics.DiagnosticSource.dll ... zipping: ref/System.Diagnostics.FileVersionInfo.dll ... zipping: ref/System.Diagnostics.Process.dll ... zipping: ref/System.Diagnostics.StackTrace.dll ... zipping: ref/System.Diagnostics.TextWriterTraceListener.dll ... zipping: ref/System.Diagnostics.Tools.dll ... zipping: ref/System.Diagnostics.TraceSource.dll ... zipping: ref/System.Diagnostics.Tracing.dll ... zipping: ref/System.dll ... zipping: ref/System.Drawing.dll ... zipping: ref/System.Drawing.Primitives.dll ... zipping: ref/System.Dynamic.Runtime.dll ... zipping: ref/System.Globalization.Calendars.dll ... zipping: ref/System.Globalization.dll ... zipping: ref/System.Globalization.Extensions.dll ... zipping: ref/System.IO.Compression.Brotli.dll ... zipping: ref/System.IO.Compression.dll ... zipping: ref/System.IO.Compression.FileSystem.dll ... zipping: ref/System.IO.Compression.ZipFile.dll ... zipping: ref/System.IO.dll ... zipping: ref/System.IO.FileSystem.dll ... zipping: ref/System.IO.FileSystem.DriveInfo.dll ... zipping: ref/System.IO.FileSystem.Primitives.dll ... zipping: ref/System.IO.FileSystem.Watcher.dll ... zipping: ref/System.IO.IsolatedStorage.dll ... zipping: ref/System.IO.MemoryMappedFiles.dll ... zipping: ref/System.IO.Pipes.dll ... zipping: ref/System.IO.UnmanagedMemoryStream.dll ... zipping: ref/System.Linq.dll ... zipping: ref/System.Linq.Expressions.dll ... zipping: ref/System.Linq.Parallel.dll ... zipping: ref/System.Linq.Queryable.dll ... zipping: ref/System.Memory.dll ... zipping: ref/System.Net.dll ... zipping: ref/System.Net.Http.dll ... zipping: ref/System.Net.HttpListener.dll ... zipping: ref/System.Net.Mail.dll ... zipping: ref/System.Net.NameResolution.dll ... zipping: ref/System.Net.NetworkInformation.dll ... zipping: ref/System.Net.Ping.dll ... zipping: ref/System.Net.Primitives.dll ... zipping: ref/System.Net.Requests.dll ... zipping: ref/System.Net.Security.dll ... zipping: ref/System.Net.ServicePoint.dll ... zipping: ref/System.Net.Sockets.dll ... zipping: ref/System.Net.WebClient.dll ... zipping: ref/System.Net.WebHeaderCollection.dll ... zipping: ref/System.Net.WebProxy.dll ... zipping: ref/System.Net.WebSockets.Client.dll ... zipping: ref/System.Net.WebSockets.dll ... zipping: ref/System.Numerics.dll ... zipping: ref/System.Numerics.Vectors.dll ... zipping: ref/System.ObjectModel.dll ... zipping: ref/System.Reflection.DispatchProxy.dll ... zipping: ref/System.Reflection.dll ... zipping: ref/System.Reflection.Emit.dll ... zipping: ref/System.Reflection.Emit.ILGeneration.dll ... zipping: ref/System.Reflection.Emit.Lightweight.dll ... zipping: ref/System.Reflection.Extensions.dll ... zipping: ref/System.Reflection.Metadata.dll ... zipping: ref/System.Reflection.Primitives.dll ... zipping: ref/System.Reflection.TypeExtensions.dll ... zipping: ref/System.Resources.Reader.dll ... zipping: ref/System.Resources.ResourceManager.dll ... zipping: ref/System.Resources.Writer.dll ... zipping: ref/System.Runtime.CompilerServices.Unsafe.dll ... zipping: ref/System.Runtime.CompilerServices.VisualC.dll ... zipping: ref/System.Runtime.dll ... zipping: ref/System.Runtime.Extensions.dll ... zipping: ref/System.Runtime.Handles.dll ... zipping: ref/System.Runtime.InteropServices.dll ... zipping: ref/System.Runtime.InteropServices.RuntimeInformation.dll ... zipping: ref/System.Runtime.InteropServices.WindowsRuntime.dll ... zipping: ref/System.Runtime.Intrinsics.dll ... zipping: ref/System.Runtime.Loader.dll ... zipping: ref/System.Runtime.Numerics.dll ... zipping: ref/System.Runtime.Serialization.dll ... zipping: ref/System.Runtime.Serialization.Formatters.dll ... zipping: ref/System.Runtime.Serialization.Json.dll ... zipping: ref/System.Runtime.Serialization.Primitives.dll ... zipping: ref/System.Runtime.Serialization.Xml.dll ... zipping: ref/System.Security.Claims.dll ... zipping: ref/System.Security.Cryptography.Algorithms.dll ... zipping: ref/System.Security.Cryptography.Csp.dll ... zipping: ref/System.Security.Cryptography.Encoding.dll ... zipping: ref/System.Security.Cryptography.Primitives.dll ... zipping: ref/System.Security.Cryptography.X509Certificates.dll ... zipping: ref/System.Security.dll ... zipping: ref/System.Security.Principal.dll ... zipping: ref/System.Security.SecureString.dll ... zipping: ref/System.ServiceModel.Web.dll ... zipping: ref/System.ServiceProcess.dll ... zipping: ref/System.Text.Encoding.CodePages.dll ... zipping: ref/System.Text.Encoding.dll ... zipping: ref/System.Text.Encoding.Extensions.dll ... zipping: ref/System.Text.Encodings.Web.dll ... zipping: ref/System.Text.Json.dll ... zipping: ref/System.Text.RegularExpressions.dll ... zipping: ref/System.Threading.Channels.dll ... zipping: ref/System.Threading.dll ... zipping: ref/System.Threading.Overlapped.dll ... zipping: ref/System.Threading.Tasks.Dataflow.dll ... zipping: ref/System.Threading.Tasks.dll ... zipping: ref/System.Threading.Tasks.Extensions.dll ... zipping: ref/System.Threading.Tasks.Parallel.dll ... zipping: ref/System.Threading.Thread.dll ... zipping: ref/System.Threading.ThreadPool.dll ... zipping: ref/System.Threading.Timer.dll ... zipping: ref/System.Transactions.dll ... zipping: ref/System.Transactions.Local.dll ... zipping: ref/System.ValueTuple.dll ... zipping: ref/System.Web.dll ... zipping: ref/System.Web.HttpUtility.dll ... zipping: ref/System.Windows.dll ... zipping: ref/System.Xml.dll ... zipping: ref/System.Xml.Linq.dll ... zipping: ref/System.Xml.ReaderWriter.dll ... zipping: ref/System.Xml.Serialization.dll ... zipping: ref/System.Xml.XDocument.dll ... zipping: ref/System.Xml.XmlDocument.dll ... zipping: ref/System.Xml.XmlSerializer.dll ... zipping: ref/System.Xml.XPath.dll ... zipping: ref/System.Xml.XPath.XDocument.dll ... zipping: ref/WindowsBase.dll ... zipping: ru/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: ru/Microsoft.CodeAnalysis.resources.dll ... zipping: tr/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: tr/Microsoft.CodeAnalysis.resources.dll ... zipping: zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: zh-Hans/Microsoft.CodeAnalysis.resources.dll ... zipping: zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll ... zipping: zh-Hant/Microsoft.CodeAnalysis.resources.dll ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.Aliases.psm1 ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.Completers.psm1 ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.dll ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.dll-Help.xml ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.Format.ps1xml ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.psd1 ... zipping: Modules/aws.tools.common/4.0.5.0/AWS.Tools.Common.XML ... zipping: Modules/aws.tools.common/4.0.5.0/AWSSDK.Core.dll ... zipping: Modules/aws.tools.common/4.0.5.0/AWSSDK.SecurityToken.dll ... zipping: Modules/aws.tools.common/4.0.5.0/ImportGuard.ps1 ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.Aliases.psm1 ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.Completers.psm1 ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.dll ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.dll-Help.xml ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.Format.ps1xml ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.psd1 ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWS.Tools.S3.XML ... zipping: Modules/aws.Tools.s3/4.0.5.0/AWSSDK.S3.dll ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Host/Microsoft.PowerShell.Host.psd1 ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1 ... zipping: runtimes/unix/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/CimCmdlets/CimCmdlets.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/Diagnostics.format.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/Event.format.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/GetEvent.types.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Host/Microsoft.PowerShell.Host.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.WSMan.Management/Microsoft.WSMan.Management.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/Microsoft.WSMan.Management/WSMan.format.ps1xml ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/PSDiagnostics/PSDiagnostics.psd1 ... zipping: runtimes/win/lib/netcoreapp3.1/Modules/PSDiagnostics/PSDiagnostics.psm1 Created publish archive (C:\Users\ME\AppData\Local\Temp\pslambda_test\bin\Release\netcoreapp3.1\pslambda_test.zip). Updating code for existing function pslambda_test VERBOSE: Removing staging directory C:\Users\ME\AppData\Local\Temp\pslambda_test ```

Output of an invocation:

``` START RequestId: 8fe85231-ef07-4fd6-aec4-3d9dde076de2 Version: $LATEST [Information] - This function started successfully END RequestId: 8fe85231-ef07-4fd6-aec4-3d9dde076de2 REPORT RequestId: 8fe85231-ef07-4fd6-aec4-3d9dde076de2 Duration: 58.00 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 147 MB ```

ashishdhingra commented 3 years ago

Hi @jgardsentry,

Good afternoon.

I was going through the issue backlog and came across this issue. I followed your steps exactly, but unable to reproduce the issue. Here is the output in AWS Console while invoking (testing) the Lambda function:

START RequestId: f3bc1e14-f4fb-4d95-8649-08e94308c37c Version: $LATEST
Importing module ./Modules/AWS.Tools.Common/4.1.2.0/AWS.Tools.Common.psd1
Importing module ./Modules/AWS.Tools.S3/4.1.2.0/AWS.Tools.S3.psd1
[Information] - This function started successfully
END RequestId: f3bc1e14-f4fb-4d95-8649-08e94308c37c
REPORT RequestId: f3bc1e14-f4fb-4d95-8649-08e94308c37c  Duration: 317.29 ms Billed Duration: 400 ms Memory Size: 512 MB Max Memory Used: 166 MB Init Duration: 2340.77 ms

Contents of pslambda_test.ps1:

#Requires -Modules 'AWS.Tools.Common','AWS.Tools.S3'
write-host "This function started successfully"

Publish Command:

$PublishSettings = @{
  Name = "pslambda_test"
  ScriptPath = "./pslambda_test.ps1"
  Memory = 512
  Timeout = 20
  Region = 'us-east-2'
  IAMRoleArn = 'arn:aws:iam::<accountid>:role/<lambdarolename>'
  Verbose = $true
}

Import-Module 'aws.tools.common','aws.tools.s3'
Import-module 'AWSLambdaPSCore'

Publish-AWSPowerShellLambda @PublishSettings

Output of $psversiontable:

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Darwin 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Output of get-module:

Name                            Version
----                            -------
AWS.Tools.Common                4.1.2.0
AWS.Tools.S3                    4.1.2.0
AWSLambdaPSCore                 2.0.0.0
ImportGuard                     0.0
Microsoft.PowerShell.Management 7.0.0.0
Microsoft.PowerShell.Utility    7.0.0.0
PSReadLine                      2.0.0

Output of Get-AWSPowerShellVersion:

AWS Tools for PowerShell               
Version 4.1.2.0  
Copyright 2012-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET                                          
Core Runtime Version 3.5.1.23
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Release notes: https://github.com/aws/aws-tools-for-powershell/blob/master/CHANGELOG.md

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]

Please try with the latest version of AWS Tools and Modules, and confirm if the issue is resolved.

Thanks, Ashish

github-actions[bot] commented 3 years ago

This issue has not recieved a response in 2 weeks. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.