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

Glue Crawler: Add catalog target config #9430

Merged
merged 8 commits into from
Aug 1, 2019
Merged

Glue Crawler: Add catalog target config #9430

merged 8 commits into from
Aug 1, 2019

Conversation

azclub
Copy link
Contributor

@azclub azclub commented Jul 21, 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 #8631

Release note for CHANGELOG:

resource/aws_glue_crawler: Add `catalog_target` attribute

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSGlueCrawler_CatalogTarget'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSGlueCrawler_CatalogTarget -timeout 120m
=== RUN   TestAccAWSGlueCrawler_CatalogTarget
=== PAUSE TestAccAWSGlueCrawler_CatalogTarget
=== RUN   TestAccAWSGlueCrawler_CatalogTarget_Multiple
=== PAUSE TestAccAWSGlueCrawler_CatalogTarget_Multiple
=== CONT  TestAccAWSGlueCrawler_CatalogTarget
=== CONT  TestAccAWSGlueCrawler_CatalogTarget_Multiple
--- PASS: TestAccAWSGlueCrawler_CatalogTarget (126.62s)
--- PASS: TestAccAWSGlueCrawler_CatalogTarget_Multiple (174.49s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	174.556s

@azclub azclub requested a review from a team July 21, 2019 10:15
@ghost ghost added size/S Managed by automation to categorize the size of a PR. service/glue Issues and PRs that pertain to the glue service. labels Jul 21, 2019
@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Jul 21, 2019
@ghost ghost added size/L 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/M Managed by automation to categorize the size of a PR. labels Jul 21, 2019
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Jul 21, 2019
@ghost ghost added the documentation Introduces or discusses updates to documentation. label Jul 21, 2019
@azclub azclub changed the title [WIP] Glue Crawler: Add catalog target config Glue Crawler: Add catalog target config Jul 21, 2019
@azclub
Copy link
Contributor Author

azclub commented Jul 31, 2019

Hi @bflad, could you review this, please?

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 @azclub 👋 Thanks so much for contributing this. Its off to a great start. A few little testing things and we should be able to get this in. Please reach out if you have any questions or do not have time to implement the feedback. 😄

EOF

data "aws_iam_policy" "AWSGlueServiceRole" {
arn = "arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep the usage of the aws_partition data source -- we run this acceptance testing across multiple AWS partitions like GovCloud (US).

Suggested change
arn = "arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole"
arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSGlueServiceRole"

@@ -1391,6 +1516,146 @@ resource "aws_glue_crawler" "test" {
`, rName, rName, path1, path2)
}

func testAccGlueCrawlerConfig_CatalogTarget_TableResources(tables []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.

Rather than creating a separate function that generates configuration, this can be accomplished within configurations that potentially need multiple tables by using count and count.index with the resource. e.g.

resource "aws_glue_catalog_table" "test" {
  count = %d

  database_name = "${aws_glue_catalog_database.test.name}"
  name          = "%s${count.index}"
  table_type    = "EXTERNAL_TABLE"

  storage_descriptor {
    location      = "s3://${aws_s3_bucket.default.bucket}"
  }
}

The count would be the number to create and the table name would be rName. References can be simply:

aws_glue_catalog_table.test[*].name

return config
}

func testAccGlueCrawlerConfig_CatalogTarget_TableList(tables []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.

Using the noted reference above (aws_glue_catalog_table.test[*].name), this function is extraneous. 👍

}
EOF
}
`, rName, rName, rName, rName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Go's fmt verbs support indexing, e.g. %[1]q so repeated arguments are not necessary. 👍

@bflad bflad self-assigned this Jul 31, 2019
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 31, 2019
@azclub
Copy link
Contributor Author

azclub commented Aug 1, 2019

Hi @bflad, thank you very much for the review! I've updated the PR, it's ready for review again.

The CI failed on make lint and make test, but those commands didn't throw the same error in local. Do you know how to fix it?

Output from acceptance testing:

TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSGlueCrawler_CatalogTarget -timeout 120m
=== RUN   TestAccAWSGlueCrawler_CatalogTarget
=== PAUSE TestAccAWSGlueCrawler_CatalogTarget
=== RUN   TestAccAWSGlueCrawler_CatalogTarget_Multiple
=== PAUSE TestAccAWSGlueCrawler_CatalogTarget_Multiple
=== CONT  TestAccAWSGlueCrawler_CatalogTarget
=== CONT  TestAccAWSGlueCrawler_CatalogTarget_Multiple
--- PASS: TestAccAWSGlueCrawler_CatalogTarget (100.13s)
--- PASS: TestAccAWSGlueCrawler_CatalogTarget_Multiple (146.67s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	146.720s

@bflad bflad self-requested a review August 1, 2019 14:25
@bflad bflad added this to the v2.23.0 milestone Aug 1, 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.

Looks great, @azclub, thank you! 🚀

--- PASS: TestAccAWSGlueCrawler_Role_ARN_NoPath (39.80s)
--- PASS: TestAccAWSGlueCrawler_recreates (45.98s)
--- PASS: TestAccAWSGlueCrawler_SchemaChangePolicy (57.52s)
--- PASS: TestAccAWSGlueCrawler_Configuration (59.91s)
--- PASS: TestAccAWSGlueCrawler_SecurityConfiguration (62.03s)
--- PASS: TestAccAWSGlueCrawler_TablePrefix (61.69s)
--- PASS: TestAccAWSGlueCrawler_JdbcTarget_Exclusions (62.45s)
--- PASS: TestAccAWSGlueCrawler_CatalogTarget_Multiple (69.91s)
--- PASS: TestAccAWSGlueCrawler_JdbcTarget_Multiple (70.66s)
--- PASS: TestAccAWSGlueCrawler_Classifiers (71.49s)
--- PASS: TestAccAWSGlueCrawler_Role_Name_Path (76.75s)
--- PASS: TestAccAWSGlueCrawler_Description (79.83s)
--- PASS: TestAccAWSGlueCrawler_S3Target_Multiple (80.29s)
--- PASS: TestAccAWSGlueCrawler_Role_ARN_Path (81.78s)
--- PASS: TestAccAWSGlueCrawler_CatalogTarget (84.14s)
--- PASS: TestAccAWSGlueCrawler_Schedule (86.09s)
--- PASS: TestAccAWSGlueCrawler_S3Target_Exclusions (91.98s)
--- PASS: TestAccAWSGlueCrawler_JdbcTarget (91.91s)
--- PASS: TestAccAWSGlueCrawler_S3Target (124.60s)
--- PASS: TestAccAWSGlueCrawler_DynamodbTarget (124.71s)

@bflad bflad merged commit 0adad4a into hashicorp:master Aug 1, 2019
bflad added a commit that referenced this pull request Aug 1, 2019
@ghost
Copy link

ghost commented Aug 7, 2019

This has been released in version 2.23.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 2, 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 2, 2019
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. enhancement Requests to existing resources that expand the functionality or scope. service/glue Issues and PRs that pertain to the glue service. size/XL 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.

Add ability for aws_glue_crawler to use catalog table targets
2 participants