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

chore: add region argument to target_table in aws_glue_catalog_table #34817

Merged
6 changes: 6 additions & 0 deletions .changelog/34817.txt
Original file line number Diff line number Diff line change
@@ -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.
```
12 changes: 12 additions & 0 deletions internal/service/glue/catalog_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func ResourceCatalogTable() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"region": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions internal/service/glue/catalog_table_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ func DataSourceCatalogTable() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"region": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions internal/service/glue/catalog_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/d/glue_catalog_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions website/docs/r/glue_catalog_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading