将PowerShell脚本发布到AWS Lambda

时间:2018-12-05 15:12:30

标签: amazon-web-services powershell aws-lambda powershell-core powershell-v6.0

我正在尝试将PowerShell核心脚本部署到AWS Lambda。我正在从EC2实例进行部署。

我正在关注AWS Lambda Deployment Package in PowerShell - AWS Lambda,并尝试部署他们描述的确切脚本。当我运行时,它似乎可以正常工作:

Publish-AWSPowerShellLambda -ScriptPath .\LambdaPSTest.ps1 -Name LambdaPSTest -Region us-east-1

但随后出现以下错误。

  

检索LambdaPSTest函数的配置时出错:响应状态代码未指示成功:404(未找到)。

我感到困惑的是,自从我在调用publish时设置了该值以来,为什么它似乎在该区域中断了。

Error publishing PowerShell Lambda Function: -1

CALLSTACK:
Command                     Arguments
-------                     ---------
_deployProject
Publish-AWSPowerShellLambda {{Region=us-east-1$null}, {Region=us-east-1$null}, {Region=us-east-1$null}, {Region=us-ea...
<ScriptBlock>               {{=$null}, {=$null}, {=$null}, {=$null}}
At C:\Users\Administrator\Documents\PowerShell\Modules\AWSLambdaPSCore\1.1.0.0\Private\_DeploymentFunctions.ps1:194 char:13
+             throw $msg
+             ~~~~~~~~~~
+ CategoryInfo          : OperationStopped: (Error publishin...
:String) [], RuntimeException
+ FullyQualifiedErrorId : Error publishing PowerShell Lambda Function: -1
CALLSTACK:
Command                     Arguments
-------                     ---------
_deployProject
Publish-AWSPowerShellLambda {{Region=us-east-1$null}, {Region=us-east-1$null}, {Region=us-east-1$null}, {Region=us-ea...
<ScriptBlock>               {{=$null}, {=$null}, {=$null}, {=$null}}

1 个答案:

答案 0 :(得分:0)

我认为问题最终与企业环境中的安全设置有关。

万一其他人遇到了这个问题,对我有用的是运行

New-AWSPowerShellLambdaPackage -ScriptPath ./fileUploader.ps1 -OutputPackage fileUploader.zip

然后手动上传到AWS Lambda