我正在尝试使用AWS powershell更新S3存储桶中项目的元数据。我正在使用脚本:
Set-AWSCredentials -ProfileName S3Test ;
write-S3Object -BucketName myS3bucket `
-Key Folder/Subfolder/Myfile.txt `
-Content "Myfile.txt `
-Metadata @{"x-amz-meta-custommetadata" = "TESTMEtadata"} `
-Headers @{"Content-Type" = "binary/octet-stream"} ;
我能够在我的计算机上从我自己的帐户成功运行此脚本,但是当我尝试使用服务帐户自动执行此脚本时,我收到错误消息:
write-S3Object : A WebException with status TrustFailure was thrown.
At line:1 char:1
+ write-S3Object -BucketName myS3Bucket `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation:
(Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Obje
t], InvalidOperationException
+ FullyQualifiedErrorId :
Amazon.Runtime.AmazonServiceException,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet
根据我在类似问题上发现的内容,我尝试将此行添加到我的脚本中:
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ;
然而,这会导致不同的错误消息:
write-S3Object : A WebException with status RecieveFailure was thrown.
At line:1 char:1
+ write-S3Object -BucketName myS3Bucket `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation:
(Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Obje
t], InvalidOperationException
+ FullyQualifiedErrorId :
Amazon.Runtime.AmazonServiceException,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet
有没有人知道可能导致这些问题的原因以及我将如何解决这些问题?
答案 0 :(得分:0)
似乎比较使用在
中定义的内容运行回调 [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
我不确定是什么根据我读到的内容触发了它,但回调似乎是在服务帐户上设置的。
尝试将其设置为:
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null
参考:
https://forrestbrazeal.com/2015/06/15/adventures-in-aws-the-worlds-scariest-stack-trace/
答案 1 :(得分:0)
检查服务器上的日期。
我在访问AWS端点时遇到了同样的错误,但解决方案更简单......我正在测试一个过程,我将服务器上的日期设置为几个月,这导致AWS连接过程抛出请求。