Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 53c7192

Browse files
author
thisisaaronland
committed
add -debug flag to cmd/aws-sign-request
1 parent 9d61aa9 commit 53c7192

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ Usage of ./bin/aws-sign-request:
157157
If empty then the value of the region associated with the AWS config/credentials will be used.
158158
-credentials-uri string
159159
A valid aaronland/go-aws-auth config URI.
160+
-debug
161+
Enable verbose debug logging to STDOUT.
160162
-do
161163
If true then execute the signed request and output the response to STDOUT.
162164
-header value

cmd/aws-sign-request/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"github.com/aaronland/go-aws-auth"
1818
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
19+
"github.com/aws/smithy-go/logging"
1920
"github.com/sfomuseum/go-flags/multi"
2021
)
2122

@@ -30,6 +31,7 @@ func main() {
3031
var method string
3132
var uri string
3233
var do bool
34+
var debug bool
3335

3436
flag.StringVar(&api_signing_name, "api-signing-name", "", "The name the API uses to identify the service the request is scoped to.")
3537
flag.StringVar(&api_signing_region, "api-signing-region", "", "If empty then the value of the region associated with the AWS config/credentials will be used.")
@@ -39,6 +41,7 @@ func main() {
3941
flag.StringVar(&credentials_uri, "credentials-uri", "", "A valid aaronland/go-aws-auth config URI.")
4042
flag.BoolVar(&do, "do", false, "If true then execute the signed request and output the response to STDOUT.")
4143
flag.Var(&headers, "header", "Zero or more HTTP headers to assign to the request in the form of key=value.")
44+
flag.BoolVar(&debug, "debug", false, "Enable verbose debug logging to STDOUT.")
4245

4346
flag.Parse()
4447

@@ -97,7 +100,12 @@ func main() {
97100
req.Header.Set(h.Key(), h.Value().(string))
98101
}
99102

100-
signer := v4.NewSigner()
103+
signer := v4.NewSigner(func(opts *v4.SignerOptions) {
104+
if debug {
105+
opts.LogSigning = true
106+
opts.Logger = logging.NewStandardLogger(os.Stdout)
107+
}
108+
})
101109

102110
err = signer.SignHTTP(ctx, creds, req, body_sha256, api_signing_name, api_signing_region, time.Now())
103111

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/aws/aws-sdk-go-v2/service/iam v1.31.3
1111
github.com/aws/aws-sdk-go-v2/service/ssm v1.49.4
1212
github.com/aws/aws-sdk-go-v2/service/sts v1.28.5
13+
github.com/aws/smithy-go v1.20.1
1314
github.com/go-ini/ini v1.67.0
1415
github.com/sfomuseum/go-flags v0.10.0
1516
github.com/sfomuseum/iso8601duration v1.1.0
@@ -24,6 +25,5 @@ require (
2425
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6 // indirect
2526
github.com/aws/aws-sdk-go-v2/service/sso v1.20.3 // indirect
2627
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.3 // indirect
27-
github.com/aws/smithy-go v1.20.1 // indirect
2828
github.com/jmespath/go-jmespath v0.4.0 // indirect
2929
)

0 commit comments

Comments
 (0)