provider/aws: output the log group name when create fails (#11812)

* provider/aws: output the log group name when create fails

* adjusted formatting to match other error output

* fixup detailed error message for ResourceAlreadyExistsException

* forgot an import

* show the log group name regardless of error type
This commit is contained in:
netjunki 2017-02-10 00:38:14 -08:00 committed by Radek Simko
parent ccb3674c04
commit 5d053754e6
1 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/hashicorp/errwrap"
)
@ -54,7 +55,10 @@ func resourceAwsCloudWatchLogGroupCreate(d *schema.ResourceData, meta interface{
LogGroupName: aws.String(d.Get("name").(string)),
})
if err != nil {
return fmt.Errorf("Creating CloudWatch Log Group failed: %s", err)
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "ResourceAlreadyExistsException" {
return fmt.Errorf("Creating CloudWatch Log Group failed: %s: The CloudWatch Log Group '%s' already exists.", err, d.Get("name").(string))
}
return fmt.Errorf("Creating CloudWatch Log Group failed: %s '%s'", err, d.Get("name"))
}
d.SetId(d.Get("name").(string))