-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
set-public-policy
command
#81
Comments
Relevant code from the s3-credentials/s3_credentials/cli.py Lines 376 to 378 in 3f7bb39
s3-credentials/s3_credentials/cli.py Lines 405 to 409 in 3f7bb39
|
Here's a prototype: @cli.command()
@click.argument("bucket")
@common_boto3_options
def set_public_policy(bucket, **boto_options):
"""
Set public policy for bucket
This will allow GET requests for anonymous users.
s3-credentials set-public-policy my-bucket
"""
s3 = make_client("s3", **boto_options)
if not bucket_exists(s3, bucket):
raise click.ClickException("Bucket {} does not exists".format(bucket))
bucket_policy = policies.bucket_policy_allow_all_get(bucket)
try:
s3.put_bucket_policy(Bucket=bucket, Policy=json.dumps(bucket_policy))
except botocore.exceptions.ClientError as e:
raise click.ClickException(e) I built that for: |
Design decision: should this be reversible? If so, what should that command be? Should there be a way to see if a bucket has this policy or not, or a way to list the bucket policy in general? Then it needs tests and docs. |
Relevant docs: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-example-bucket-policies.html A bucket only gets one bucket policy at a time. |
I added that here: |
Mainly for if you run
s3-credentials create mybucket --create-bucket
but forget to add--public
and want to add that later.The text was updated successfully, but these errors were encountered: