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

Only accept lowercase names for aws_glue_catalog_database and aws_glue_catalog_table #8288

Closed
wants to merge 11 commits into from

Conversation

jukie
Copy link
Contributor

@jukie jukie commented Apr 11, 2019

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 #7958

Changes proposed in this pull request:

  • Validate database name provided is only comprised of lowercase alphanumeric characters, underscores, and hyphens

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSGlueCatalogDatabase_validation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSGlueCatalogDatabase_validation -timeout 120m
=== RUN   TestAccAWSGlueCatalogDatabase_validation
=== PAUSE TestAccAWSGlueCatalogDatabase_validation
=== CONT  TestAccAWSGlueCatalogDatabase_validation
--- PASS: TestAccAWSGlueCatalogDatabase_validation (1.61s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1.650s
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSGlueCatalogTable_validation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSGlueCatalogTable_validation -timeout 120m
=== RUN   TestAccAWSGlueCatalogTable_validation
=== PAUSE TestAccAWSGlueCatalogTable_validation
=== CONT  TestAccAWSGlueCatalogTable_validation
--- PASS: TestAccAWSGlueCatalogTable_validation (0.75s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	0.793s

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/glue Issues and PRs that pertain to the glue service. labels Apr 11, 2019
@ghost ghost added size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/XS Managed by automation to categorize the size of a PR. labels Apr 12, 2019
@ghost ghost added size/L Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. and removed size/M Managed by automation to categorize the size of a PR. labels Apr 14, 2019
@jukie
Copy link
Contributor Author

jukie commented Apr 14, 2019

Updated acceptance test results:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSGlueCatalogTable_validation' && make testacc TEST=./aws TESTARGS='-run=TestAccAWSGlueCatalogDatabase_validation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSGlueCatalogTable_validation -timeout 120m
=== RUN   TestAccAWSGlueCatalogTable_validation
=== PAUSE TestAccAWSGlueCatalogTable_validation
=== CONT  TestAccAWSGlueCatalogTable_validation
--- PASS: TestAccAWSGlueCatalogTable_validation (4.34s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	4.398s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSGlueCatalogDatabase_validation -timeout 120m
=== RUN   TestAccAWSGlueCatalogDatabase_validation
=== PAUSE TestAccAWSGlueCatalogDatabase_validation
=== CONT  TestAccAWSGlueCatalogDatabase_validation
--- PASS: TestAccAWSGlueCatalogDatabase_validation (1.95s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	(cached)

@jukie
Copy link
Contributor Author

jukie commented Apr 15, 2019

This is ready for a follow-up review when there's time.

@jukie
Copy link
Contributor Author

jukie commented May 15, 2019

@charlyx is this ready to merge?

@jukie
Copy link
Contributor Author

jukie commented Jun 10, 2019

I see this pr was approved a while ago, is it ready to merge?

@aeschright aeschright requested a review from a team June 26, 2019 16:42
@carinadigital
Copy link
Contributor

@jukie Are going to bring this PR up to date? I'm happy to help.

@@ -14,7 +14,7 @@ Provides a Glue Catalog Database Resource. You can refer to the [Glue Developer

```hcl
resource "aws_glue_catalog_database" "aws_glue_catalog_database" {
name = "MyCatalogDatabase"
name = "my_datalog_database"
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo here

name = "MyCatalogTable"
database_name = "MyCatalogDatabase"
name = "my_catalog_table"
database_name = "my_datalog_database"
Copy link
Contributor

Choose a reason for hiding this comment

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

And same one here

name = "MyCatalogTable"
database_name = "MyCatalogDatabase"
name = "my_datalog_table"
database_name = "my_datalog_database"
Copy link
Contributor

Choose a reason for hiding this comment

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

last one

if len(value) > 255 {
errors = append(errors, fmt.Errorf("%q cannot be more than 255 characters long", k))
}
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also validate the whole string against a validity regex to stop special characters getting through. e.g.

^[a-z0-9_-]*$

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that regex is valid, \uDC00-\uDBFF is an invalid range. I only have minimal experience using unicode expressions but as long as I've converted to go notation correctly I think we've found a bug.
https://play.golang.org/p/jhV8pEEjPrT

Copy link
Contributor Author

@jukie jukie Sep 28, 2019

Choose a reason for hiding this comment

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

Additionally, special characters are in fact allowed in both the table and database names. Technically, Uppercase is allowed in the api call as well but it's just converted to lowercase after.
This proposal for only accepting lowercase in terraform is because otherwise terraform would always attempt to reapply changes. I think my validator works but if you'd like me to make changes I can.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I think your right 👍

@jukie
Copy link
Contributor Author

jukie commented Sep 27, 2019

Thanks, I'll rebase and apply your suggested changes

@carinadigital
Copy link
Contributor

Let's hope someone from hashicorp will pick this up now :-)

@jukie
Copy link
Contributor Author

jukie commented Sep 30, 2019

Thanks @carinadigital!
#8384 is another one that's been open for awhile if you have time to take a look.

@jukie jukie mentioned this pull request Oct 11, 2019
@jukie jukie removed the request for review from a team October 11, 2019 21:15
@bflad bflad added this to the v3.0.0 milestone Oct 11, 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 submitting this, @jukie. I left some minor feedback items below and marked this for our upcoming 3.0.0 version (likely in the next month or so) since technically it can break existing configurations that might be working around the perpetual difference with ignore_changes. Please reach out if you have any questions or do not have time to implement the feedback items.

@@ -12,6 +13,54 @@ import (
"github.com/hashicorp/terraform/terraform"
)

func TestAccAWSGlueCatalogDatabase_importBasic(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We're in the process of removing import-only testing (#8944). Please add the ImportState testing to existing tests if its not present, although TestAccAWSGlueCatalogDatabase_full on master looks like it includes it already.

@@ -208,6 +257,21 @@ resource "aws_glue_catalog_database" "test" {
`, rInt, desc)
}

func testAccGlueCatalogDatabase_validation(rName string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarity, it might be better if this was named against the attribute its testing:

Suggested change
func testAccGlueCatalogDatabase_validation(rName string) string {
func testAccGlueCatalogDatabaseConfigName(rName string) string {

return fmt.Sprintf(`
resource "aws_glue_catalog_database" "test" {
name = "%s"
description = "validation test"
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the rest of the arguments are optional and we're only looking to test the name attribute, I'd suggest removing the other arguments from the test configuration.

@tzzh
Copy link

tzzh commented Feb 19, 2020

@jukie are you still working on this ? I ran into this issue as well and I am happy to help if I can.

@breathingdust breathingdust removed this from the v3.0.0 milestone May 19, 2020
@jukie jukie requested a review from a team July 21, 2020 18:26
@DrFaust92
Copy link
Collaborator

Hey @@jukie, can you rebase?

@DrFaust92
Copy link
Collaborator

Closing in favour of #16052

@DrFaust92 DrFaust92 closed this Nov 5, 2020
@ghost
Copy link

ghost commented Dec 5, 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 as resolved and limited conversation to collaborators Dec 5, 2020
@justinretzolk justinretzolk added the partner Contribution from a partner. label May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. partner Contribution from a partner. service/glue Issues and PRs that pertain to the glue service. size/L 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.

Database name in aws_glue_catalog_database and aws_glue_catalog_table should be lowercase
9 participants