-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Conversation
Updated acceptance test results:
|
This is ready for a follow-up review when there's time. |
@charlyx is this ready to merge? |
I see this pr was approved a while ago, is it ready to merge? |
@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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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_-]*$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even better use AWS's
https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-databases.html
https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-common.html#aws-glue-api-regex-oneLine
[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\t]*
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
Thanks, I'll rebase and apply your suggested changes |
Let's hope someone from hashicorp will pick this up now :-) |
Thanks @carinadigital! |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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:
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" |
There was a problem hiding this comment.
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.
@jukie are you still working on this ? I ran into this issue as well and I am happy to help if I can. |
Hey @@jukie, can you rebase? |
Closing in favour of #16052 |
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! |
Community Note
Fixes #7958
Changes proposed in this pull request:
Output from acceptance testing: