Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove client-vpn endpoints from state when they are missing #10187

Merged
merged 1 commit into from
Sep 24, 2019
Merged

fix: remove client-vpn endpoints from state when they are missing #10187

merged 1 commit into from
Sep 24, 2019

Conversation

GabrielCastro
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

BUG FIXES:
resource/client_vpn_endpoint: Fix crash after an endpoint has been removed outside terraform

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

@GabrielCastro GabrielCastro requested a review from a team September 20, 2019 19:59
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/ec2 Issues and PRs that pertain to the ec2 service. labels Sep 20, 2019
@bflad bflad added the bug Addresses a defect in current functionality. label Sep 24, 2019
@bflad bflad self-assigned this Sep 24, 2019
@bflad bflad added this to the v2.30.0 milestone Sep 24, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, @GabrielCastro 🚀 We can test this code via:

func TestAccAwsEc2ClientVpnEndpoint_disappears(t *testing.T) {
	rStr := acctest.RandString(5)

	resource.ParallelTest(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProvidersWithTLS,
		CheckDestroy: testAccCheckAwsEc2ClientVpnEndpointDestroy,
		Steps: []resource.TestStep{
			{
				Config: testAccEc2ClientVpnEndpointConfig(rStr),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAwsEc2ClientVpnEndpointExists("aws_ec2_client_vpn_endpoint.test"),
					testAccCheckAwsEc2ClientVpnEndpointDisappears("aws_ec2_client_vpn_endpoint.test"),
				),
				ExpectNonEmptyPlan: true,
			},
		},
	})
}

func testAccCheckAwsEc2ClientVpnEndpointDisappears(name string) resource.TestCheckFunc {
	return func(s *terraform.State) error {
		rs, ok := s.RootModule().Resources[name]
		if !ok {
			return fmt.Errorf("Not found: %s", name)
		}

		conn := testAccProvider.Meta().(*AWSClient).ec2conn

		input := &ec2.DeleteClientVpnEndpointInput{
			ClientVpnEndpointId: aws.String(rs.Primary.ID),
		}

		_, err := conn.DeleteClientVpnEndpoint(input)

		return err
	}
}

Previously before code update:

--- FAIL: TestAccAwsEc2ClientVpnEndpoint_disappears (14.36s)
    testing.go:569: Step 0 error: errors during follow-up refresh:

        Error: Error reading Client VPN endpoint: InvalidClientVpnEndpointId.NotFound: Endpoint cvpn-endpoint-0f615b0f07cfbe2ba does not exist

Output from acceptance testing:

--- PASS: TestAccAwsEc2ClientVpnEndpoint_disappears (16.12s)

bflad added a commit that referenced this pull request Sep 24, 2019
…out-of-band resource removal handling

Reference: #10187

Previously before code update:

```
--- FAIL: TestAccAwsEc2ClientVpnEndpoint_disappears (14.36s)
    testing.go:569: Step 0 error: errors during follow-up refresh:

        Error: Error reading Client VPN endpoint: InvalidClientVpnEndpointId.NotFound: Endpoint cvpn-endpoint-0f615b0f07cfbe2ba does not exist
```

Output from acceptance testing:

```
--- PASS: TestAccAwsEc2ClientVpnEndpoint_disappears (16.12s)
```
@bflad bflad merged commit 965f3e9 into hashicorp:master Sep 24, 2019
bflad added a commit that referenced this pull request Sep 24, 2019
@ghost
Copy link

ghost commented Sep 26, 2019

This has been released in version 2.30.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 1, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants