Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 将代码构建/管道访问限制为两个存储桶,访问被拒绝_Amazon Web Services_Amazon S3_Amazon Iam_Aws Codebuild_Aws Iam - Fatal编程技术网

Amazon web services 将代码构建/管道访问限制为两个存储桶,访问被拒绝

Amazon web services 将代码构建/管道访问限制为两个存储桶,访问被拒绝,amazon-web-services,amazon-s3,amazon-iam,aws-codebuild,aws-iam,Amazon Web Services,Amazon S3,Amazon Iam,Aws Codebuild,Aws Iam,目前使用S3完全访问,我的代码构建工作正常。但是,当我试图通过下面列出的策略限制codebuild的访问时,我会收到一条关于我需要访问的私有repo中的文件夹的错误消息。其中一个S3存储桶是通常的codepipeline存储桶,另一个是我们托管的私有maven repo(它需要AWS访问密钥) 以下是IAM政策: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:ListAllMyBucket

目前使用S3完全访问,我的代码构建工作正常。但是,当我试图通过下面列出的策略限制codebuild的访问时,我会收到一条关于我需要访问的私有repo中的文件夹的错误消息。其中一个S3存储桶是通常的codepipeline存储桶,另一个是我们托管的私有maven repo(它需要AWS访问密钥)

以下是IAM政策:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*"
},
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::codepipeline-us-east-1-etcetc/*",
"arn:aws:s3::: labs-maven-repo"
]
},
{
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::codepipeline-us-east-1-etcetc/*",
"arn:aws:s3:::labs-maven-repo"
]
}
]
}
下面是我在代码构建的构建阶段遇到的错误。另外,有趣的是,值得注意的是,maven repo中的文件夹列在下面的错误消息中,而不是S3 bucket本身

WARNING Could not transfer metadata com.project.metadata:data-model:1.0-SNAPSHOT/maven-metadata.xml from/to -server name given in settings.xml file- (s3://labs-maven-repo/release): Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; 

WARNING Could not transfer metadata com.project.metadata:data-model:1.0-SNAPSHOT/maven-metadata.xml from/to -server name given in settings.xml file- (s3://labs-maven-repo/snapshot): Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; 
提前谢谢大家


另外,这是我的第一篇堆栈溢出帖子,因此如果有其他信息或我可以提供的任何内容,请告诉我。

如果您正在从存储桶中检索数据,则只需在IAM策略中添加该存储桶的读取权限。 如果要将数据上载到该存储桶,则需要在IAM策略中添加该存储桶的写入权限。
然后请重试。

对于s3:ListBucket,请将该bucket指定为不带通配符的资源。因此:

“arn:aws:s3:::代码管道-us-east-1-etcetc”

而不是

“arn:aws:s3:::代码管道-us-east-1-etcetc/*”

对于对象操作(作为s3:*)使用

“arn:aws:s3:::实验室maven repo/*”

而不是

“arn:aws:s3:::实验室maven repo”

对于S3,需要考虑三种不同的操作:

  • 对所有bucket的操作:指定多个bucket作为资源。 例如,“资源”:“*”

  • 对bucket本身的操作将bucket指定为资源。 例如,“资源”:[“arn:aws:s3:::codepipeline-us-east-1-etcetc”,“arn:aws:s3:::labs maven repo”]

  • 对bucket中对象的操作指定bucket的任何前缀。 例如,“资源”:[“arn:aws:s3:::代码管道-us-east-1-etcetc/”,“arn:aws:s3:::实验室maven repo/”]


  • 它们看起来像一些不同寻常的S3 bucket名称:前导空格、嵌入空格和两端的破折号。可能值得检查它们是否符合命名约定:啊!我很抱歉,我试图让桶名尽可能通用。破折号是为了避免在另一个论坛上格式化!谢谢你为我指出这一点。我现在就修。