Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions config/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"runtime"
"slices"
"strings"
"time"
"unicode/utf8"

"github.com/getsops/sops/v3/cmd/sops/formats"
Expand Down Expand Up @@ -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()...")

Copy link
Contributor

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

Copy link
Author

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()...")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wakeful have a look ??

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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()
Copy link
Collaborator

Choose a reason for hiding this comment

The 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:
https://github.com/gruntwork-io/terragrunt/blob/main/internal/discovery/discovery.go#L970

accountID, err := awshelper.GetAWSAccountID(ctx.Context, awsConfig)
if err == nil {
return accountID, nil
duration := time.Since(start)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Expand Down
2 changes: 2 additions & 0 deletions config/locals.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func attemptEvaluateLocals(
errs := &errors.MultiError{}

for _, attr := range attrs {
l.Tracef("evaluating local %q...", attr.Name)

if diags := canEvaluateLocals(attr.Expr, evaluatedLocals); !diags.HasErrors() {
evaluatedVal, err := attr.Value(evalCtx)
if err != nil {
Expand Down