From 5d8662d5dab2f8dab5cfd67d03d24df960783519 Mon Sep 17 00:00:00 2001 From: julius-bonial Date: Sun, 29 Jan 2017 20:19:48 +0100 Subject: [PATCH] fix wrong usage of hashicorp/errwrap (#11500) According to https://github.com/hashicorp/errwrap '{{err}}' has to be used instead of '%s' Without this patch, error output from terraform is missing important information: * aws_cloudwatch_log_group.logs: Error Getting CloudWatch Logs Tag List: %s With this patch, I get the important information. E.g.: * aws_cloudwatch_log_group.logs: Error Getting CloudWatch Logs Tag List: AccessDeniedException: User: arn:aws:sts::XYZ:assumed-role/AAA-BBB-CCC/terraform-assuming-role-assume-role-ReadOnly is not authorized to perform: logs:ListTagsLogGroup on resource: arn:aws:logs:us-east-1:XYZ:log-group:logs:log-stream: --- builtin/providers/aws/auth_helpers.go | 2 +- builtin/providers/aws/resource_aws_cloudwatch_log_group.go | 2 +- builtin/providers/aws/resource_aws_cloudwatch_log_stream.go | 4 ++-- builtin/providers/postgresql/provider.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/providers/aws/auth_helpers.go b/builtin/providers/aws/auth_helpers.go index fab4928b6..907bf3de4 100644 --- a/builtin/providers/aws/auth_helpers.go +++ b/builtin/providers/aws/auth_helpers.go @@ -30,7 +30,7 @@ func GetAccountInfo(iamconn *iam.IAM, stsconn *sts.STS, authProviderName string) setOptionalEndpoint(cfg) sess, err := session.NewSession(cfg) if err != nil { - return "", "", errwrap.Wrapf("Error creating AWS session: %s", err) + return "", "", errwrap.Wrapf("Error creating AWS session: {{err}}", err) } metadataClient := ec2metadata.New(sess) diff --git a/builtin/providers/aws/resource_aws_cloudwatch_log_group.go b/builtin/providers/aws/resource_aws_cloudwatch_log_group.go index 85913c087..929d1c3ed 100644 --- a/builtin/providers/aws/resource_aws_cloudwatch_log_group.go +++ b/builtin/providers/aws/resource_aws_cloudwatch_log_group.go @@ -218,7 +218,7 @@ func flattenCloudWatchTags(d *schema.ResourceData, conn *cloudwatchlogs.CloudWat LogGroupName: aws.String(d.Get("name").(string)), }) if err != nil { - return nil, errwrap.Wrapf("Error Getting CloudWatch Logs Tag List: %s", err) + return nil, errwrap.Wrapf("Error Getting CloudWatch Logs Tag List: {{err}}", err) } if tagsOutput != nil { output := make(map[string]interface{}, len(tagsOutput.Tags)) diff --git a/builtin/providers/aws/resource_aws_cloudwatch_log_stream.go b/builtin/providers/aws/resource_aws_cloudwatch_log_stream.go index ba66f4843..6557787a7 100644 --- a/builtin/providers/aws/resource_aws_cloudwatch_log_stream.go +++ b/builtin/providers/aws/resource_aws_cloudwatch_log_stream.go @@ -48,7 +48,7 @@ func resourceAwsCloudWatchLogStreamCreate(d *schema.ResourceData, meta interface LogStreamName: aws.String(d.Get("name").(string)), }) if err != nil { - return errwrap.Wrapf("Creating CloudWatch Log Stream failed: %s", err) + return errwrap.Wrapf("Creating CloudWatch Log Stream failed: {{err}}", err) } d.SetId(d.Get("name").(string)) @@ -86,7 +86,7 @@ func resourceAwsCloudWatchLogStreamDelete(d *schema.ResourceData, meta interface } _, err := conn.DeleteLogStream(params) if err != nil { - return errwrap.Wrapf("Error deleting CloudWatch Log Stream: %s", err) + return errwrap.Wrapf("Error deleting CloudWatch Log Stream: {{err}}", err) } return nil diff --git a/builtin/providers/postgresql/provider.go b/builtin/providers/postgresql/provider.go index ab26af8b9..a51aa6388 100644 --- a/builtin/providers/postgresql/provider.go +++ b/builtin/providers/postgresql/provider.go @@ -102,7 +102,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { client, err := config.NewClient() if err != nil { - return nil, errwrap.Wrapf("Error initializing PostgreSQL client: %s", err) + return nil, errwrap.Wrapf("Error initializing PostgreSQL client: {{err}}", err) } return client, nil