-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Debug or Trace logging for get_aws_account_id() #4751
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
base: main
Are you sure you want to change the base?
Changes from all commits
28b26b1
1f49175
2971d9a
95cc4e5
2199ed0
d26f7af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import ( | |
| "runtime" | ||
| "slices" | ||
| "strings" | ||
| "time" | ||
| "unicode/utf8" | ||
|
|
||
| "github.com/getsops/sops/v3/cmd/sops/formats" | ||
|
|
@@ -632,17 +633,26 @@ func getAWSAccountAlias(ctx *ParsingContext, l log.Logger) (string, error) { | |
|
|
||
| // Return the AWS account id associated to the current set of credentials | ||
| func getAWSAccountID(ctx *ParsingContext, l log.Logger) (string, error) { | ||
| l.Tracef("Invoking get_aws_account_id()...") | ||
|
|
||
| awsConfig, err := awshelper.CreateAwsConfig(ctx.Context, l, nil, ctx.TerragruntOptions) | ||
| if err != nil { | ||
| l.Errorf("get_aws_account_id(): failed to create AWS config: %v", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this. The error should be propagated correctly to make it clear what happened. Consider wrapping the error below instead. fmt.Errorf("failed to create AWS config for get_aws_account_id(): %w", err) |
||
| return "", err | ||
| } | ||
|
|
||
| start := time.Now() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this timer. If you want to instrument code to determine durations, it should be done with our OpenTelemetry integration: |
||
| accountID, err := awshelper.GetAWSAccountID(ctx.Context, awsConfig) | ||
| if err == nil { | ||
| return accountID, nil | ||
| duration := time.Since(start) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above about the timer |
||
|
|
||
| if err != nil { | ||
| l.Errorf("get_aws_account_id(): error retriving accound ID: %v", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above about removing this |
||
| return "", err | ||
| } | ||
|
|
||
| return "", err | ||
| l.Tracef("get_aws_account_id(): resolved account ID %q in %s", accountID, duration) | ||
|
|
||
| return accountID, nil | ||
| } | ||
|
|
||
| // Return the ARN of the AWS identity associated with the current set of credentials | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ticket also mentioned adding extra logs to this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean like this
l.Debugf("TRACE: invoking get_aws_account_id()...")There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wakeful have a look ??