Skip to content

Commit

Permalink
Addressing review comments II
Browse files Browse the repository at this point in the history
  • Loading branch information
gazoakley committed Oct 31, 2018
1 parent 9f4422c commit 6b53580
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions aws/resource_aws_ec2_capacity_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ func resourceAwsEc2CapacityReservationCreate(d *schema.ResourceData, meta interf
opts.Tenancy = aws.String(v.(string))
}

restricted := meta.(*AWSClient).IsChinaCloud()
if !restricted {

if v, ok := d.GetOk("tags"); ok {
tagsSpec := make([]*ec2.TagSpecification, 0)

if v, ok := d.GetOk("tags"); ok {
if len(tagsSpec) > 0 {
tags := tagsFromMap(v.(map[string]interface{}))

spec := &ec2.TagSpecification{
Expand All @@ -155,9 +153,7 @@ func resourceAwsEc2CapacityReservationCreate(d *schema.ResourceData, meta interf
}

tagsSpec = append(tagsSpec, spec)
}

if len(tagsSpec) > 0 {
opts.TagSpecifications = tagsSpec
}
}
Expand Down Expand Up @@ -216,15 +212,12 @@ func resourceAwsEc2CapacityReservationUpdate(d *schema.ResourceData, meta interf
conn := meta.(*AWSClient).ec2conn

d.Partial(true)
restricted := meta.(*AWSClient).IsChinaCloud()

if d.HasChange("tags") {
if !d.IsNewResource() || restricted {
if err := setTags(conn, d); err != nil {
return err
} else {
d.SetPartial("tags")
}
if err := setTags(conn, d); err != nil {
return err
} else {
d.SetPartial("tags")
}
}

Expand Down

0 comments on commit 6b53580

Please sign in to comment.