我试图在AWS CodePipeline中设置一个管道,在触发来自CodeCommit的更改之后,CodeBuild就启动了。它执行buildspec.yaml
文件中所述的命令,当它要将内容同步到S3桶时失败。
目前,我已经将AmazonS3FullAccess
策略附加到了相应的AmazonS3FullAccess
服务角色,但是它给了我以下错误:
[Container] 2020/03/20 16:13:22 Running command aws s3 sync ./dist/ProjectName/ s3://project-name-dev
fatal error: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied
可能会有什么问题?
发布于 2020-03-21 03:25:53
将对象写入S3桶需要两个位置的权限:
关于“桶政策”中的角色
既然您已经将'AmazonS3FullAccess‘添加到CodeBuild服务角色中,那么如果它不允许Codebuild角色编写,请检查Bucket策略。您可以在桶上添加以下Bucket策略来修复这个问题:
{
"Sid": "Stmt1561445614665",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<Account_Number>:role/service-role/<your-codebuild-service-role>". <===== Update with your codebuild service role ARN
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucketname", <===== Update with your bucket name
"arn:aws:s3:::bucketname/*" <===== Update with your bucket name
]
}
https://stackoverflow.com/questions/60777966
复制相似问题