diff --git a/.changelog/34817.txt b/.changelog/34817.txt new file mode 100644 index 00000000000..1601ccf42d3 --- /dev/null +++ b/.changelog/34817.txt @@ -0,0 +1,6 @@ +```release-note:enhancement +resource/aws_glue_catalog_table: Add `region` attribute to `target_table` block. +``` +```release-note:enhancement +data-source/aws_glue_catalog_table: Add `region` attribute to `target_table` block. +``` diff --git a/internal/service/glue/catalog_table.go b/internal/service/glue/catalog_table.go index 7933d91e4f0..663223cfc64 100644 --- a/internal/service/glue/catalog_table.go +++ b/internal/service/glue/catalog_table.go @@ -342,6 +342,10 @@ func ResourceCatalogTable() *schema.Resource { Type: schema.TypeString, Required: true, }, + "region": { + Type: schema.TypeString, + Optional: true, + }, }, }, }, @@ -1119,6 +1123,10 @@ func expandTableTargetTable(tfMap map[string]interface{}) *glue.TableIdentifier apiObject.Name = aws.String(v) } + if v, ok := tfMap["region"].(string); ok && v != "" { + apiObject.Region = aws.String(v) + } + return apiObject } @@ -1141,6 +1149,10 @@ func flattenTableTargetTable(apiObject *glue.TableIdentifier) map[string]interfa tfMap["name"] = aws.StringValue(v) } + if v := apiObject.Region; v != nil { + tfMap["region"] = aws.StringValue(v) + } + return tfMap } diff --git a/internal/service/glue/catalog_table_data_source.go b/internal/service/glue/catalog_table_data_source.go index 9eeba51b8eb..2c56a525fc4 100644 --- a/internal/service/glue/catalog_table_data_source.go +++ b/internal/service/glue/catalog_table_data_source.go @@ -299,6 +299,10 @@ func DataSourceCatalogTable() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "region": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, diff --git a/internal/service/glue/catalog_table_test.go b/internal/service/glue/catalog_table_test.go index f6daa12a853..8c68ba2ec85 100644 --- a/internal/service/glue/catalog_table_test.go +++ b/internal/service/glue/catalog_table_test.go @@ -1415,6 +1415,8 @@ resource "aws_glue_catalog_table" "test" { func testAccCatalogTableConfig_target(rName string) string { return fmt.Sprintf(` +data "aws_region" "current" {} + resource "aws_glue_catalog_database" "test" { name = %[1]q } @@ -1427,6 +1429,7 @@ resource "aws_glue_catalog_table" "test" { catalog_id = aws_glue_catalog_table.test2.catalog_id database_name = aws_glue_catalog_table.test2.database_name name = aws_glue_catalog_table.test2.name + region = data.aws_region.current.name } } diff --git a/website/docs/d/glue_catalog_table.html.markdown b/website/docs/d/glue_catalog_table.html.markdown index d0479f12ba8..d318a39870c 100644 --- a/website/docs/d/glue_catalog_table.html.markdown +++ b/website/docs/d/glue_catalog_table.html.markdown @@ -115,3 +115,4 @@ This data source exports the following attributes in addition to the arguments a * `catalog_id` - ID of the Data Catalog in which the table resides. * `database_name` - Name of the catalog database that contains the target table. * `name` - Name of the target table. +* `region` - Region of the target table. diff --git a/website/docs/r/glue_catalog_table.html.markdown b/website/docs/r/glue_catalog_table.html.markdown index 7598ebf5722..6773b76b049 100644 --- a/website/docs/r/glue_catalog_table.html.markdown +++ b/website/docs/r/glue_catalog_table.html.markdown @@ -190,6 +190,7 @@ To add an index to an existing table, see the [`glue_partition_index` resource]( * `catalog_id` - (Required) ID of the Data Catalog in which the table resides. * `database_name` - (Required) Name of the catalog database that contains the target table. * `name` - (Required) Name of the target table. +* `region` - (Optional) Region of the target table. ## Attribute Reference