backend/s3: Add debug logging and user agent

Porting over previous behavior from terraform-provider-aws.
This commit is contained in:
Brian Flad 2019-02-27 12:59:08 -05:00
parent 47443e39ad
commit e34a97abca
No known key found for this signature in database
GPG Key ID: EC6252B42B012823
1 changed files with 8 additions and 0 deletions

View File

@ -10,7 +10,9 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
awsbase "github.com/hashicorp/aws-sdk-go-base"
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/version"
)
// New creates a new backend for S3 remote state.
@ -296,6 +298,7 @@ func (b *Backend) configure(ctx context.Context) error {
AssumeRolePolicy: data.Get("assume_role_policy").(string),
AssumeRoleSessionName: data.Get("session_name").(string),
CredsFilename: data.Get("shared_credentials_file").(string),
DebugLogging: logging.IsDebugOrHigher(),
IamEndpoint: data.Get("iam_endpoint").(string),
MaxRetries: data.Get("max_retries").(int),
Profile: data.Get("profile").(string),
@ -305,6 +308,11 @@ func (b *Backend) configure(ctx context.Context) error {
SkipMetadataApiCheck: data.Get("skip_metadata_api_check").(bool),
StsEndpoint: data.Get("sts_endpoint").(string),
Token: data.Get("token").(string),
UserAgentProducts: []*awsbase.UserAgentProduct{
{Name: "APN", Version: "1.0"},
{Name: "HashiCorp", Version: "1.0"},
{Name: "Terraform", Version: version.String()},
},
}
sess, err := awsbase.GetSession(cfg)