From 6c3cc5ff4f913b65b8a31dd240d77e75972aca36 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 16 Jan 2020 21:35:48 -0800 Subject: [PATCH] resource/aws_ec2_client_vpn_endpoint: Properly set status value into Terraform state (#11497) Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/9954 Previously: ``` /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_ec2_client_vpn_endpoint.go:226:18: R004: ResourceData.Set() incompatible value type: *github.com/aws/aws-sdk-go/service/ec2.ClientVpnEndpointStatus ``` Output from acceptance testing: ``` --- PASS: TestAccAwsEc2ClientVpnEndpoint_basic (21.32s) ``` --- aws/resource_aws_ec2_client_vpn_endpoint.go | 6 +++++- aws/resource_aws_ec2_client_vpn_endpoint_test.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_ec2_client_vpn_endpoint.go b/aws/resource_aws_ec2_client_vpn_endpoint.go index 62d05390495..6352e65e163 100644 --- a/aws/resource_aws_ec2_client_vpn_endpoint.go +++ b/aws/resource_aws_ec2_client_vpn_endpoint.go @@ -223,7 +223,11 @@ func resourceAwsEc2ClientVpnEndpointRead(d *schema.ResourceData, meta interface{ d.Set("server_certificate_arn", result.ClientVpnEndpoints[0].ServerCertificateArn) d.Set("transport_protocol", result.ClientVpnEndpoints[0].TransportProtocol) d.Set("dns_name", result.ClientVpnEndpoints[0].DnsName) - d.Set("status", result.ClientVpnEndpoints[0].Status) + + if result.ClientVpnEndpoints[0].Status != nil { + d.Set("status", result.ClientVpnEndpoints[0].Status.Code) + } + d.Set("split_tunnel", result.ClientVpnEndpoints[0].SplitTunnel) err = d.Set("authentication_options", flattenAuthOptsConfig(result.ClientVpnEndpoints[0].AuthenticationOptions)) diff --git a/aws/resource_aws_ec2_client_vpn_endpoint_test.go b/aws/resource_aws_ec2_client_vpn_endpoint_test.go index eda8ad6692c..8aa1f6bd734 100644 --- a/aws/resource_aws_ec2_client_vpn_endpoint_test.go +++ b/aws/resource_aws_ec2_client_vpn_endpoint_test.go @@ -86,6 +86,7 @@ func TestAccAwsEc2ClientVpnEndpoint_basic(t *testing.T) { testAccCheckAwsEc2ClientVpnEndpointExists("aws_ec2_client_vpn_endpoint.test"), resource.TestCheckResourceAttr("aws_ec2_client_vpn_endpoint.test", "authentication_options.#", "1"), resource.TestCheckResourceAttr("aws_ec2_client_vpn_endpoint.test", "authentication_options.0.type", "certificate-authentication"), + resource.TestCheckResourceAttr("aws_ec2_client_vpn_endpoint.test", "status", ec2.ClientVpnEndpointStatusCodePendingAssociate), ), },