Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS IAM policy change for #146

Open
joanfabregat opened this issue May 3, 2022 · 1 comment
Open

AWS IAM policy change for #146

joanfabregat opened this issue May 3, 2022 · 1 comment

Comments

@joanfabregat
Copy link

joanfabregat commented May 3, 2022

This is not really a bug but a warning following the commit b041c03 which introduces a change in the required AWS permissions policy for the account used by schickling/mysql-backup-s3.

Previously schickling/mysql-backup-s3 required an account with only this (very simple) AWS policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Resource": [
                "arn:aws:s3:::***BUCKET_NAME***/*",
                "arn:aws:s3:::***BUCKET_NAME***"
            ]
        }
    ]
}

Since the addition of the following line the backup fails with the above policy.

EXISTS_ERR=`aws $AWS_ARGS s3api head-bucket --bucket "$S3_BUCKET" 2>&1 || true`

The reported error message is:

Bucket BUCKET_NAME not found (or owned by someone else), attempting to create
An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

The policy now requires s3:ListBucket in order to execute aws s3api head-bucket (as documented here).

The required minimum AWS permissions policy is now:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject", 
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::***BUCKET_NAME***/*",
                "arn:aws:s3:::***BUCKET_NAME***"
            ]
        }
    ]
}

Justed wanted to give a heads up to other developers running into this problem.

@matiasgarciaisaia
Copy link
Contributor

For anyone around here, I'm proposing to opt-out of the new behaviour via a S3_ENSURE_BUCKET_EXISTS=no environment variable in #153 - opinions welcomed in the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants