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

Change output of get-bucket-policy #1851

Closed
sabriedd opened this issue Mar 15, 2016 · 8 comments
Closed

Change output of get-bucket-policy #1851

sabriedd opened this issue Mar 15, 2016 · 8 comments
Labels
closed-for-staleness feature-request A feature should be added or improved.

Comments

@sabriedd
Copy link

The current output of get-bucket-policy is a JSON with a single Policy key containing a string value.

aws s3api get-bucket-policy --bucket my-bucket
{
    "Policy": "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::my-bucket/*\"},{\"Sid\":\"\",\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::my-bucket/secret/*\"}]}"
}

Actually, that string is JSON formated, so it would make sens to have the output as follow :

aws s3api get-bucket-policy --bucket my-bucket
{
    "Policy": {
        "Version": "2008-10-17",
        "Statement": [
            {
                "Sid": "",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::my-bucket/*"
            },
            {
                "Sid": "",
                "Effect": "Deny",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::my-bucket/secret/*"
            }
        ]
    }
}

it would also make the API more consistent, since all other get-bucket-* API return a valid JSON structure

This was tested with aws-cli/1.10.1 Python/2.7.9 Linux/4.0.0-kali1-amd64 botocore/1.3.23

@JordonPhillips JordonPhillips added the feature-request A feature should be added or improved. label Mar 15, 2016
@JordonPhillips
Copy link
Member

While we wouldn't be able to change this in botocore for backwards compatibility reasons, we may be able to alter the CLI output. Thanks for letting us know!

@morkot
Copy link

morkot commented Sep 8, 2017

@SpoonBoy as far as I understood the issue appears when output is json, so aws-cli have to output json inside json. If you use --output text then it will output it correctly:

❯ aws --version
aws-cli/1.11.148 Python/2.7.10 Darwin/15.6.0 botocore/1.7.6

~
❯ aws s3api get-bucket-policy --bucket my-bucket --output text | jq .

@ASayre
Copy link
Contributor

ASayre commented Feb 6, 2018

Good Morning!

We're closing this issue here on GitHub, as part of our migration to UserVoice for feature requests involving the AWS CLI.

This will let us get the most important features to you, by making it easier to search for and show support for the features you care the most about, without diluting the conversation with bug reports.

As a quick UserVoice primer (if not already familiar): after an idea is posted, people can vote on the ideas, and the product team will be responding directly to the most popular suggestions.

We’ve imported existing feature requests from GitHub - Search for this issue there!

And don't worry, this issue will still exist on GitHub for posterity's sake. As it’s a text-only import of the original post into UserVoice, we’ll still be keeping in mind the comments and discussion that already exist here on the GitHub issue.

GitHub will remain the channel for reporting bugs.

Once again, this issue can now be found by searching for the title on: https://aws.uservoice.com/forums/598381-aws-command-line-interface

-The AWS SDKs & Tools Team

@ASayre ASayre closed this as completed Feb 6, 2018
@salmanwaheed
Copy link

salmanwaheed commented Feb 6, 2018 via email

@salmanwaheed
Copy link

salmanwaheed commented Feb 6, 2018 via email

@jamesls jamesls reopened this Apr 6, 2018
@jamesls
Copy link
Member

jamesls commented Apr 6, 2018

Based on community feedback, we have decided to return feature requests to GitHub issues.

@chadasapp
Copy link

chadasapp commented Aug 20, 2018

The workaround I ended up with was piping to jq like this:
aws s3api get-bucket-policy --bucket=foo | jq '.Policy | fromjson'

Agree with reporter that having a way to do this natively would be ideal, even if with an optional extra param for back-compat reasons.

@github-actions
Copy link

Greetings! It looks like this issue hasn’t been active in longer than one year. We encourage you to check if this is still an issue in the latest release. Because it has been longer than one year since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment to prevent automatic closure, or if the issue is already closed, please feel free to reopen it.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Sep 18, 2020
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

7 participants