From e308635405b1222506a705db83c09e1818afd728 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Wed, 5 Feb 2020 16:40:14 -0500 Subject: [PATCH] resource/aws_ec2_client_vpn_endpoint: Refactor to use keyvaluetags package Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/10688 Output from acceptance testing: ``` --- PASS: TestAccAwsEc2ClientVpnEndpoint_disappears (20.98s) --- PASS: TestAccAwsEc2ClientVpnEndpoint_basic (32.30s) --- PASS: TestAccAwsEc2ClientVpnEndpoint_withDNSServers (36.48s) --- PASS: TestAccAwsEc2ClientVpnEndpoint_splitTunnel (39.03s) --- PASS: TestAccAwsEc2ClientVpnEndpoint_withLogGroup (41.00s) --- PASS: TestAccAwsEc2ClientVpnEndpoint_tags (51.32s) --- PASS: TestAccAwsEc2ClientVpnEndpoint_msAD (1806.58s) ``` --- aws/resource_aws_ec2_client_vpn_endpoint.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/aws/resource_aws_ec2_client_vpn_endpoint.go b/aws/resource_aws_ec2_client_vpn_endpoint.go index 6352e65e163..b7cc304189a 100644 --- a/aws/resource_aws_ec2_client_vpn_endpoint.go +++ b/aws/resource_aws_ec2_client_vpn_endpoint.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func resourceAwsEc2ClientVpnEndpoint() *schema.Resource { @@ -240,7 +241,7 @@ func resourceAwsEc2ClientVpnEndpointRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error setting connection_log_options: %s", err) } - err = d.Set("tags", tagsToMap(result.ClientVpnEndpoints[0].Tags)) + err = d.Set("tags", keyvaluetags.Ec2KeyValueTags(result.ClientVpnEndpoints[0].Tags).IgnoreAws().Map()) if err != nil { return fmt.Errorf("error setting tags: %s", err) } @@ -324,10 +325,13 @@ func resourceAwsEc2ClientVpnEndpointUpdate(d *schema.ResourceData, meta interfac return fmt.Errorf("Error modifying Client VPN endpoint: %s", err) } - if err := setTags(conn, d); err != nil { - return err + 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 Client VPN Endpoint (%s) tags: %s", d.Id(), err) + } } - d.SetPartial("tags") d.Partial(false) return resourceAwsEc2ClientVpnEndpointRead(d, meta)