Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

amazon web services - CodeIgniter3 - AWS S3 Bucket - PHP Warning coming but file get upload successfully

ISSUE DETAILS Files get uploaded successfully but, warning message is encountered

ERROR

Severity: User Warning

Message: S3::putBucket(acetute-uploads, private, ): [AccessDenied] Access Denied

Filename: libraries/S3.php
  • KMS key is generated,
  • Added in IAM ROLE user policy
  • Bucket policy is added correctly

I guess the issue is related to policies

Bucket Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:Get*",
                "s3:Delete*",
                "s3:Put*"
            ],
            "Resource": [
                "arn:aws:s3:::BUCKETNAME/*"
            ]
        },
        {
            "Sid": "ListBucket",
            "Effect": "Allow",
            "Action": "s3:List*",
            "Resource": "arn:aws:s3:::BUCKETNAME"
        },
        {
            "Sid": "KMSAccess",
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt",
                "kms:GenerateDataKey"
            ],
            "Resource": "arn:aws:kms:REGION:111111111:key/xxxxxxxxxxx"
        }
    ]
}

IAM User Policy

{
    "Version": "2012-10-17",
    "Id": "Policy1488494182833",
    "Statement": [
        {
            "Sid": "Stmt1488493308547",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::11111111:user/USER"
            },
            "Action": [
                "s3:Get*",
                "s3:Put*",
                "s3:Delete*"
            ],
            "Resource": "arn:aws:s3:::BUCKETNAME/*"
        },
        {
            "Sid": "ListBucket",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::11111111:user/USER"
            },
            "Action": "s3:List*",
            "Resource": "arn:aws:s3:::BUCKETNAME"
        }
    ]
}

Please help how can I remove warning!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Issue resolved by changing bucket policy

{
    "Version": "2012-10-17",
    "Id": "Policy1488494182833",
    "Statement": [
        {
            "Sid": "Stmt1488493308547",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111111:user/USER"
            },
            "Action": [
                "s3:Get*",
                "s3:Put*",
                "s3:Delete*",
                "s3:List*"
            ],
            "Resource": [
                "arn:aws:s3:::BUCKET_NAME/*",
                "arn:aws:s3:::BUCKET_NAME"
            ]
        }
    ]
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...