假定IAM用户从Jenkins CI上载S3的角色



我正在尝试使用jenkins CI的S3UPLOAD,我在Jenkins控制台中添加了IAM用户S3_USER凭证并使用使用WASTAWS(区域:S3Region,recortentials,recertentials:s3user(。但是我的IAM用户S3_USER没有S3 RW策略,IAM用户必须假设角色S3_USERROLEWITHRWPOLICY。我该怎么做?

在Jenkins IAM凭据中提供了S3_user访问权限和秘密密钥,并在IAM角色中添加了S3_USERROLEWITHRWPOLICY,以在IAM角色支持下使用。但仍然无法从詹金斯上传S3。我如何在Jenkins文件中配置以使用角色?

Finally figured out the solution:
I was using this in Jenkins CI file : 
withAWS(region: 's3Region', credentials: 'iamUser')
{
s3Upload( file:'jar', bucket:s3Bucket, path: s3Path)
}
It worked fine when iamUser has direct access to S3
but failed when iamUser has to assume role to access S3 (after adding IAM Role to Assume in credentials)
But the below worked:
 withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'iamUser']]) {
withAWS(region: 's3Region')
{
s3Upload( file:'jar', bucket:s3Bucket, path: s3Path)
}
}

最新更新