Jenkins拒绝了S3存取桶访问

时间:2017-12-21 22:33:28

标签: amazon-web-services jenkins amazon-s3

我正在尝试将构建文件从Jenkins上传到S3 Bucket。我只想要Cloudfront&用户deployer有权访问存储桶,策略如下:

{
    "Version": "2008-10-17",
    "Id": "PolicyForCloudFrontPrivateContent",
    "Statement": [
        {
            "Sid": "1",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXXXXXXX"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::samplebucket/*"
        },
        {
            "Sid": "2",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::1234567890:user/deployer"
                ]
            },
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::samplebucket",
                "arn:aws:s3:::samplebucket/*"
            ]
        }
    ]
}

此政策不允许deployer将对象上传到S3。然而,如果我将存储桶访问设置为公共,我能够成功上传Jenkins中的对象。我不希望我的桶被公开。

1 个答案:

答案 0 :(得分:1)

我正在使用具有访问密钥和秘密密钥的用户来访问具有完整权限的存储桶,但是在Jenkins->配置系统-> Amazon S3配置文件中选中了Use IAM Role。只需取消选中,您就可以开始了。也许我只需要在使用角色时检查一下。

enter image description here