Skip to content

Commit

Permalink
resource/aws_vpc_peering_connection: Refactor to use keyvaluetags pac…
Browse files Browse the repository at this point in the history
…kage (#11935)

Reference: #10688

Output from acceptance testing:

```
--- PASS: TestAccAWSVPCPeeringConnection_peerRegionAutoAccept (18.18s)
--- PASS: TestAccAWSVPCPeeringConnection_failedState (18.90s)
--- PASS: TestAccAWSVPCPeeringConnection_optionsNoAutoAccept (22.54s)
--- PASS: TestAccAWSVPCPeeringConnection_plan (30.03s)
--- PASS: TestAccAWSVPCPeeringConnection_basic (32.13s)
--- PASS: TestAccAWSVPCPeeringConnection_tags (33.94s)
--- PASS: TestAccAWSVPCPeeringConnection_region (35.88s)
--- PASS: TestAccAWSVPCPeeringConnection_options (57.71s)
--- PASS: TestAccAWSVPCPeeringConnection_accept (68.21s)
```
  • Loading branch information
bflad authored Mar 3, 2020
1 parent 22c70bc commit b793dfe
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions aws/resource_aws_vpc_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func resourceAwsVpcPeeringConnection() *schema.Resource {
Expand Down Expand Up @@ -161,7 +162,7 @@ func resourceAwsVPCPeeringRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error setting VPC Peering Connection requester information: %s", err)
}

err = d.Set("tags", tagsToMap(pc.Tags))
err = d.Set("tags", keyvaluetags.Ec2KeyValueTags(pc.Tags).IgnoreAws().Map())
if err != nil {
return fmt.Errorf("Error setting VPC Peering Connection tags: %s", err)
}
Expand Down Expand Up @@ -202,10 +203,12 @@ func resourceAwsVpcPeeringConnectionModifyOptions(d *schema.ResourceData, meta i
func resourceAwsVPCPeeringUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn

if err := setTags(conn, d); err != nil {
return err
} else {
d.SetPartial("tags")
if d.HasChange("tags") {
o, n := d.GetChange("tags")

if err := keyvaluetags.Ec2UpdateTags(conn, d.Id(), o, n); err != nil {
return fmt.Errorf("error updating EC2 VPC Peering Connection (%s) tags: %s", d.Id(), err)
}
}

pcRaw, statusCode, err := vpcPeeringConnectionRefreshState(conn, d.Id())()
Expand Down

0 comments on commit b793dfe

Please sign in to comment.