Git Product home page Git Product logo

Comments (2)

simonw avatar simonw commented on July 19, 2024
def without_response_metadata(data):
    return dict(
        (key, value) for key, value in data.items() if key != "ResponseMetadata"
    )


@cli.command()
@click.argument("bucket")
@common_boto3_options
def debug_bucket(bucket, **boto_options):
    """
    Try a bunch of diagnostics to debug a bucket

       s3-credentials debug-bucket my-bucket
    """
    s3 = make_client("s3", **boto_options)

    try:
        bucket_acl = s3.get_bucket_acl(Bucket=bucket)
        click.echo("Bucket ACL:")
        click.echo(json.dumps(without_response_metadata(bucket_acl), indent=4))
    except Exception as ex:
        print(f"Error checking bucket ACL: {ex}")

    try:
        bucket_policy_status = s3.get_bucket_policy_status(Bucket=bucket)
        click.echo("Bucket policy status:")
        click.echo(
            json.dumps(without_response_metadata(bucket_policy_status), indent=4)
        )
    except Exception as ex:
        print(f"Error checking bucket policy status: {ex}")

    try:
        bucket_public_access_block = s3.get_public_access_block(Bucket=bucket)
        click.echo("Bucket public access block:")
        click.echo(
            json.dumps(without_response_metadata(bucket_public_access_block), indent=4)
        )
    except Exception as ex:
        print(f"Error checking bucket public access block: {ex}")

from s3-credentials.

simonw avatar simonw commented on July 19, 2024

I also experimented with this command but I don't think the tool needs it:

@cli.command()
@click.argument("bucket")
@common_boto3_options
def delete_public_access_block(bucket, **boto_options):
    """
    Delete the public access block from a bucket

       s3-credentials delete-public-access-block my-bucket
    """
    s3 = make_client("s3", **boto_options)
    try:
        response = s3.delete_public_access_block(Bucket=bucket)
    except botocore.exceptions.ClientError as e:
        raise click.ClickException(e)
    click.echo(json.dumps(response, indent=4, default=str))

from s3-credentials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.