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

Fixes #8173 #8174

Merged
Merged

Conversation

thomasv314
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

Fixes #8173

Changes proposed in this pull request:

  • Recreate an aws_glue_catalog_table if it's been deleted manually outside of Terraform

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSGlueCatalogTable_recreates'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSGlueCatalogTable_recreates -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSGlueCatalogTable_recreates
--- PASS: TestAccAWSGlueCatalogTable_recreates (29.02s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       29.063s

@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/glue Issues and PRs that pertain to the glue service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Apr 3, 2019
@bflad bflad added the bug Addresses a defect in current functionality. label Apr 4, 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.

Hi @thomasv314 👋 Thanks so much for this fix and adding the test. Please see the two minor notes and we can get this in.

@@ -16,6 +16,7 @@ func resourceAwsGlueCatalogTable() *schema.Resource {
Read: resourceAwsGlueCatalogTableRead,
Update: resourceAwsGlueCatalogTableUpdate,
Delete: resourceAwsGlueCatalogTableDelete,
Exists: resourceAwsGlueCatalogTableExists,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry this might not be clear since we have a few resources that implement it, but we are preferring to skip implementing the Exists function in this provider. Could you remove this? It usually introduces unnecessary logic duplication as the beginning of each resource Read function should handle the "existence" testing logic and triggering recreation via the d.SetId("") and return nil pattern. Thanks!

@@ -265,6 +266,7 @@ func resourceAwsGlueCatalogTableRead(d *schema.ResourceData, meta interface{}) e
if isAWSErr(err, glue.ErrCodeEntityNotFoundException, "") {
log.Printf("[WARN] Glue Catalog Table (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 this should be the only fix required here.

aws/resource_aws_glue_catalog_table_test.go Outdated Show resolved Hide resolved
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Apr 4, 2019
bflad and others added 2 commits April 5, 2019 15:51
@ghost ghost added size/S Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Apr 5, 2019
@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Apr 5, 2019
@bflad bflad added this to the v2.6.0 milestone Apr 5, 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.

LGTM, thanks so much @thomasv314 🚀

Output from acceptance testing:

--- PASS: TestAccAWSGlueCatalogTable_full (10.59s)
--- PASS: TestAccAWSGlueCatalogTable_basic (10.61s)
--- PASS: TestAccAWSGlueCatalogTable_importBasic (12.12s)
--- PASS: TestAccAWSGlueCatalogTable_recreates (12.97s)
--- PASS: TestAccAWSGlueCatalogTable_update_addValues (16.20s)
--- PASS: TestAccAWSGlueCatalogTable_update_replaceValues (16.29s)

@bflad bflad merged commit b342269 into hashicorp:master Apr 5, 2019
bflad added a commit that referenced this pull request Apr 5, 2019
@thomasv314
Copy link
Contributor Author

@bflad Sorry I totally blanked on updating the PR after I pushed, but just wanted to give you a shout out and thanks for the speedy response and triage! It's much appreciated 🙏

@thomasv314 thomasv314 deleted the bugfix/recreate-glue-catalog-table branch April 9, 2019 15:29
@bflad
Copy link
Contributor

bflad commented Apr 11, 2019

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

@ghost
Copy link

ghost commented Mar 30, 2020

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 Mar 30, 2020
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/glue Issues and PRs that pertain to the glue service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resource/aws_glue_catalog_table: Prevent EntityNotFoundException when deleted outside of terraform
2 participants