Merge pull request #33825 from hashicorp/s3/log-base

backend/s3: Adds logging for `aws-sdk-go-base`
pull/33844/head
Graham Davison 3 years ago committed by GitHub
commit 56cfafe15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,6 +11,7 @@ import (
"regexp"
"sort"
"strings"
"sync"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
@ -18,8 +19,11 @@ import (
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/s3"
awsbase "github.com/hashicorp/aws-sdk-go-base/v2"
baselogging "github.com/hashicorp/aws-sdk-go-base/v2/logging"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/terraform/internal/backend"
"github.com/hashicorp/terraform/internal/configs/configschema"
"github.com/hashicorp/terraform/internal/logging"
"github.com/hashicorp/terraform/internal/tfdiags"
"github.com/hashicorp/terraform/version"
"github.com/zclconf/go-cty/cty"
@ -694,11 +698,16 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics {
}
}
log := logger()
ctx, baselog := baselogging.NewHcLogger(ctx, log)
cfg := &awsbase.Config{
AccessKey: stringAttr(obj, "access_key"),
APNInfo: stdUserAgentProducts(),
CallerDocumentationURL: "https://www.terraform.io/docs/language/settings/backends/s3.html",
CallerName: "S3 Backend",
Logger: baselog,
MaxRetries: intAttrDefault(obj, "max_retries", 5),
Profile: stringAttr(obj, "profile"),
Region: stringAttr(obj, "region"),
@ -1634,3 +1643,8 @@ func deprecatedEnvVarDiag(envvar, replacement string) tfdiags.Diagnostic {
fmt.Sprintf(`The environment variable "%s" is deprecated. Use environment variable "%s" instead.`, envvar, replacement),
)
}
var logger = sync.OnceValue(func() hclog.Logger {
l := logging.HCLogger()
return l.Named("backend-s3")
})

Loading…
Cancel
Save