Nic*_*las 5 powershell amazon-web-services jenkins amazon-iam aws-powershell
在我的 Jenkins 构建作业中,我使用此命令来承担 AWS 角色:
$Creds = (Use-STSRole -Region us-east-1 -RoleArn arn:aws:iam::$IAM_ACCOUNT_ID`:role/$IAM_ROLE -RoleSessionName jenkins).Credentials
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Use-STSRole :请求中包含的安全令牌无效。
将 AWS 角色更改为无效角色不会更改错误消息。
登录服务器并直接在Powershell中使用命令时,它工作正常。
如果我使用 AWS CLI 命令,它也可以工作:
aws sts assume-role --role-arn arn:aws:iam::%IAM_ACCOUNT_ID%:role/%IAM_ROLE% --role-session-name jenkins-deploy
Run Code Online (Sandbox Code Playgroud)
完整的错误信息:
Use-STSRole : The security token included in the request is invalid.
At C:\Users\svc-jenkins.WIN-KLBFC355P8D\AppData\Local\Temp\jenkins4822311255190032778.ps1:5 char:11
+ $Creds = (Use-STSRole -Region us-east-1 -RoleArn arn:aws:iam::$e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Amazon.PowerShe...seSTSRoleCmdlet:UseSTSRoleCmdlet) [Use-STSRole], InvalidOperationException
+ FullyQualifiedErrorId : Amazon.SecurityToken.AmazonSecurityTokenServiceException,Amazon.PowerShell.Cmdlets.STS.UseSTSRoleCmdlet
Run Code Online (Sandbox Code Playgroud)
AWS 中存储的配置文件似乎具有不正确的凭据。
使用Get-AWSCredentials列出这些:
Get-AWSCredentials -ListStoredCredentials
Run Code Online (Sandbox Code Playgroud)
然后使用Remove-AWSCredentialProfile清除:
Remove-AWSCredentialProfile -ProfileName {MyProfileName}
Run Code Online (Sandbox Code Playgroud)
如果使用旧版本的 AWS Powershell Tools,您可以改用Clear-AWSCredentials:
Clear-AWSCredentials -ProfileName <String>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3171 次 |
| 最近记录: |