From 928372fb61f5006c1f74088c58bfd2f4797c124e Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 26 Apr 2018 07:36:31 -0400 Subject: [PATCH] aws_instance: Bypass UnsupportedOperation errors with DescribeInstanceCreditSpecifications --- aws/data_source_aws_instance.go | 2 +- aws/resource_aws_instance.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aws/data_source_aws_instance.go b/aws/data_source_aws_instance.go index 865a950bea4..d2ff51ab772 100644 --- a/aws/data_source_aws_instance.go +++ b/aws/data_source_aws_instance.go @@ -407,7 +407,7 @@ func instanceDescriptionAttributes(d *schema.ResourceData, instance *ec2.Instanc } { creditSpecifications, err := getCreditSpecifications(conn, d.Id()) - if err != nil { + if err != nil && !isAWSErr(err, "UnsupportedOperation", "") { return err } if err := d.Set("credit_specification", creditSpecifications); err != nil { diff --git a/aws/resource_aws_instance.go b/aws/resource_aws_instance.go index 225db4bac6d..41c7820dd0c 100644 --- a/aws/resource_aws_instance.go +++ b/aws/resource_aws_instance.go @@ -807,7 +807,7 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error { } { creditSpecifications, err := getCreditSpecifications(conn, d.Id()) - if err != nil { + if err != nil && !isAWSErr(err, "UnsupportedOperation", "") { return err } if err := d.Set("credit_specification", creditSpecifications); err != nil { @@ -1899,10 +1899,10 @@ func getCreditSpecifications(conn *ec2.EC2, instanceId string) ([]map[string]int InstanceIds: []*string{aws.String(instanceId)}, }) if err != nil { - return nil, err + return creditSpecifications, err } - if attr.InstanceCreditSpecifications != nil { - creditSpecification["cpu_credits"] = *attr.InstanceCreditSpecifications[0].CpuCredits + if len(attr.InstanceCreditSpecifications) > 0 { + creditSpecification["cpu_credits"] = aws.StringValue(attr.InstanceCreditSpecifications[0].CpuCredits) creditSpecifications = append(creditSpecifications, creditSpecification) }