From 28b26b15d180db5b6f5d74a3f84e061be5f878c8 Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 27 Aug 2025 21:11:58 +0530 Subject: [PATCH 1/4] Debug or Trace logging for get aws account id --- config/config_helpers.go | 5 +++++ config/locals.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/config/config_helpers.go b/config/config_helpers.go index 1270b5eff7..4837b4db57 100644 --- a/config/config_helpers.go +++ b/config/config_helpers.go @@ -635,13 +635,18 @@ 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.Debugf("TRACE: Invoking get_aws_account_id()...") + session, err := awshelper.CreateAwsSession(l, nil, ctx.TerragruntOptions) if err != nil { + l.Errorf("get_aws_account_id(): failed to create AWS session: %v", err) return "", err } accountID, err := awshelper.GetAWSAccountID(session) if err == nil { + l.Errorf("get_aws_account_id(): error retriving accound ID: %v", err) return accountID, nil } diff --git a/config/locals.go b/config/locals.go index 6061b14351..8c42f633fd 100644 --- a/config/locals.go +++ b/config/locals.go @@ -132,6 +132,8 @@ func attemptEvaluateLocals( errs := &errors.MultiError{} for _, attr := range attrs { + l.Debugf("TRACE: evaluating local %q...", attr.Name) + if diags := canEvaluateLocals(attr.Expr, evaluatedLocals); !diags.HasErrors() { evaluatedVal, err := attr.Value(evalCtx) if err != nil { From 2971d9a927ba0f871dcfa00f147fc398f5ee73fc Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 28 Aug 2025 17:20:05 +0530 Subject: [PATCH 2/4] fix build problem --- config/config_helpers.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/config_helpers.go b/config/config_helpers.go index 94a8d2685d..0b39414f8b 100644 --- a/config/config_helpers.go +++ b/config/config_helpers.go @@ -633,15 +633,15 @@ 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.Debugf("TRACE: Invoking get_aws_account_id()...") - - session, err := awshelper.CreateAwsSession(l, nil, ctx.TerragruntOptions) + awsConfig, err := awshelper.CreateAwsConfig(ctx.Context, l, nil, ctx.TerragruntOptions) + // session, err := awshelper.CreateAwsSession(l, nil, ctx.TerragruntOptions) if err != nil { - l.Errorf("get_aws_account_id(): failed to create AWS session: %v", err) + l.Errorf("get_aws_account_id(): failed to create AWS config: %v", err) return "", err } - accountID, err := awshelper.GetAWSAccountID(session) + accountID, err := awshelper.GetAWSAccountID(ctx.Context, awsConfig) + // accountID, err := awshelper.GetAWSAccountID(session) if err == nil { l.Errorf("get_aws_account_id(): error retriving accound ID: %v", err) return accountID, nil From 2199ed0489198429f82d7b0e8c2717b5c9186691 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 28 Aug 2025 17:37:51 +0530 Subject: [PATCH 3/4] New fix of go build probelm --- config/config_helpers.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/config_helpers.go b/config/config_helpers.go index 0b39414f8b..95adf54aea 100644 --- a/config/config_helpers.go +++ b/config/config_helpers.go @@ -634,14 +634,12 @@ func getAWSAccountAlias(ctx *ParsingContext, l log.Logger) (string, error) { func getAWSAccountID(ctx *ParsingContext, l log.Logger) (string, error) { awsConfig, err := awshelper.CreateAwsConfig(ctx.Context, l, nil, ctx.TerragruntOptions) - // session, err := awshelper.CreateAwsSession(l, nil, ctx.TerragruntOptions) if err != nil { l.Errorf("get_aws_account_id(): failed to create AWS config: %v", err) return "", err } accountID, err := awshelper.GetAWSAccountID(ctx.Context, awsConfig) - // accountID, err := awshelper.GetAWSAccountID(session) if err == nil { l.Errorf("get_aws_account_id(): error retriving accound ID: %v", err) return accountID, nil From d26f7afb569e0fd0a4e39f695911b833fb92fb15 Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 29 Aug 2025 16:20:48 +0530 Subject: [PATCH 4/4] add extra log to get_aws_account_id function --- config/config_helpers.go | 13 ++++++++++--- config/locals.go | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config/config_helpers.go b/config/config_helpers.go index 95adf54aea..edf9d2d49a 100644 --- a/config/config_helpers.go +++ b/config/config_helpers.go @@ -11,6 +11,7 @@ import ( "runtime" "slices" "strings" + "time" "unicode/utf8" "github.com/getsops/sops/v3/cmd/sops/formats" @@ -632,6 +633,7 @@ 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 { @@ -639,13 +641,18 @@ func getAWSAccountID(ctx *ParsingContext, l log.Logger) (string, error) { return "", err } + start := time.Now() accountID, err := awshelper.GetAWSAccountID(ctx.Context, awsConfig) - if err == nil { + duration := time.Since(start) + + if err != nil { l.Errorf("get_aws_account_id(): error retriving accound ID: %v", err) - return accountID, nil + 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 diff --git a/config/locals.go b/config/locals.go index 8c42f633fd..3507d7c16d 100644 --- a/config/locals.go +++ b/config/locals.go @@ -132,7 +132,7 @@ func attemptEvaluateLocals( errs := &errors.MultiError{} for _, attr := range attrs { - l.Debugf("TRACE: evaluating local %q...", attr.Name) + l.Tracef("evaluating local %q...", attr.Name) if diags := canEvaluateLocals(attr.Expr, evaluatedLocals); !diags.HasErrors() { evaluatedVal, err := attr.Value(evalCtx)