Created
May 16, 2015 01:34
-
-
Save justincampbell/1a55a043bd926cbba0dc to your computer and use it in GitHub Desktop.
GetBucketPolicy reproduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/awslabs/aws-sdk-go/aws" | |
"github.com/awslabs/aws-sdk-go/service/s3" | |
) | |
var ( | |
bucket = "justincampbell.me" | |
region = "us-east-1" | |
) | |
func main() { | |
svc := s3.New(&aws.Config{ | |
Logger: os.Stdout, | |
LogLevel: 1, | |
LogHTTPBody: true, | |
Region: region, | |
}) | |
resp, err := svc.GetBucketPolicy(&s3.GetBucketPolicyInput{ | |
Bucket: aws.String(bucket), | |
}) | |
if awserr := aws.Error(err); awserr != nil { | |
fmt.Println("Error:", awserr.Code, awserr.Message) | |
} else if err != nil { | |
panic(err) | |
} | |
fmt.Printf("\n%#v\n", resp) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---[ CANONICAL STRING ]----------------------------- | |
GET | |
/justincampbell.me | |
policy= | |
host:s3.amazonaws.com | |
x-amz-date:20150516T013340Z | |
host;x-amz-date | |
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | |
---[ STRING TO SIGN ]-------------------------------- | |
AWS4-HMAC-SHA256 | |
20150516T013340Z | |
20150516/us-east-1/s3/aws4_request | |
d5fc784e72cf847cd7b89707c6195e693ccbcd9a63f591e8659c152b18217602 | |
----------------------------------------------------- | |
---[ REQUEST POST-SIGN ]----------------------------- | |
GET http://s3.amazonaws.com/justincampbell.me?policy= HTTP/1.1 | |
Host: s3.amazonaws.com | |
User-Agent: aws-sdk-go/0.5.0 | |
Authorization: AWS4-HMAC-SHA256 Credential=AKIAIA5ECJTPIGFZOPXA/20150516/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-date, Signature=e33615232b7e357275806c962540c4b8aa54ec8bbceceda45fe946b3a67862ef | |
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | |
X-Amz-Date: 20150516T013340Z | |
Accept-Encoding: gzip | |
----------------------------------------------------- | |
---[ RESPONSE ]-------------------------------------- | |
HTTP/1.1 200 OK | |
Content-Length: 160 | |
Content-Type: application/json | |
Date: Sat, 16 May 2015 01:33:41 GMT | |
Server: AmazonS3 | |
X-Amz-Id-2: 5oRG0pPPfhYgvnDUHqquXtWxSaupe9osfjQ5GKkjAO1JuQdoBmh2P8B9hBUHfhyk | |
X-Amz-Request-Id: 65A97AB6D6FF6F6C | |
{"Version":"2008-10-17","Statement":[{"Sid":"","Effect":"Allow","Principal":{"AWS":"*"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::justincampbell.me/*"}]} | |
----------------------------------------------------- | |
&s3.GetBucketPolicyOutput{Policy:(*string)(nil), metadataGetBucketPolicyOutput:s3.metadataGetBucketPolicyOutput{SDKShapeTraits:false}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment