diff --git a/.changelog/37891.txt b/.changelog/37891.txt new file mode 100644 index 000000000000..e6a83321f4ef --- /dev/null +++ b/.changelog/37891.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/aws_glue_catalog_table: Add `additional_locations` argument in `storage_descriptor` +``` + +```release-note:enhancement +data-source/aws_glue_catalog_table: Add `additional_locations` argument in `storage_descriptor` +``` \ No newline at end of file diff --git a/internal/service/glue/catalog_table.go b/internal/service/glue/catalog_table.go index 1be9d46f923a..05ef7e3a0bb4 100644 --- a/internal/service/glue/catalog_table.go +++ b/internal/service/glue/catalog_table.go @@ -110,6 +110,11 @@ func ResourceCatalogTable() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "additional_locations": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "bucket_columns": { Type: schema.TypeList, Optional: true, @@ -698,6 +703,10 @@ func expandStorageDescriptor(l []interface{}) *glue.StorageDescriptor { s := l[0].(map[string]interface{}) storageDescriptor := &glue.StorageDescriptor{} + if v, ok := s["additional_locations"]; ok { + storageDescriptor.AdditionalLocations = flex.ExpandStringList(v.([]interface{})) + } + if v, ok := s["columns"]; ok { storageDescriptor.Columns = expandColumns(v.([]interface{})) } @@ -903,6 +912,7 @@ func flattenStorageDescriptor(s *glue.StorageDescriptor) []map[string]interface{ storageDescriptor := make(map[string]interface{}) + storageDescriptor["additional_locations"] = flex.FlattenStringList(s.AdditionalLocations) storageDescriptor["columns"] = flattenColumns(s.Columns) storageDescriptor[names.AttrLocation] = aws.StringValue(s.Location) storageDescriptor["input_format"] = aws.StringValue(s.InputFormat) diff --git a/internal/service/glue/catalog_table_data_source.go b/internal/service/glue/catalog_table_data_source.go index b767e2bf39e1..2d8c5accdad4 100644 --- a/internal/service/glue/catalog_table_data_source.go +++ b/internal/service/glue/catalog_table_data_source.go @@ -117,6 +117,11 @@ func DataSourceCatalogTable() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "additional_locations": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "bucket_columns": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/glue/catalog_table_test.go b/internal/service/glue/catalog_table_test.go index d58dd3e52f27..6763e2d4fa9e 100644 --- a/internal/service/glue/catalog_table_test.go +++ b/internal/service/glue/catalog_table_test.go @@ -116,6 +116,7 @@ func TestAccGlueCatalogTable_full(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, description), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_1"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "int"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment"), @@ -195,6 +196,7 @@ func TestAccGlueCatalogTable_Update_addValues(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, description), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_1"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "int"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment"), @@ -255,6 +257,7 @@ func TestAccGlueCatalogTable_Update_replaceValues(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, description), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_1"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "int"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment"), @@ -304,6 +307,7 @@ func TestAccGlueCatalogTable_Update_replaceValues(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "A test table from terraform2"), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner2"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct2), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations2"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_12"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "date"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment2"), @@ -754,6 +758,7 @@ resource "aws_glue_catalog_table" "test" { view_original_text = "view_original_text_1" storage_descriptor { + additional_locations = ["my_additional_locations"] bucket_columns = ["bucket_column_1"] compressed = false input_format = "SequenceFileInputFormat" @@ -848,7 +853,7 @@ resource "aws_glue_catalog_table" "test" { "bucket_column_12", "bucket_column_2", ] - + additional_locations = ["my_additional_locations2"] compressed = true input_format = "TextInputFormat" location = "my_location2" @@ -1468,7 +1473,7 @@ resource "aws_glue_catalog_table" "test" { } storage_descriptor { - location = "s3://%[1]s/files/" + location = "s3://${aws_s3_bucket.bucket.bucket}/files/" columns { name = "my_column_1" diff --git a/website/docs/d/glue_catalog_table.html.markdown b/website/docs/d/glue_catalog_table.html.markdown index d318a39870c3..efe784b8f8bc 100644 --- a/website/docs/d/glue_catalog_table.html.markdown +++ b/website/docs/d/glue_catalog_table.html.markdown @@ -60,6 +60,7 @@ This data source exports the following attributes in addition to the arguments a ### storage_descriptor +* `additional_locations` - List of locations that point to the path where a Delta table is located * `bucket_columns` - List of reducer grouping columns, clustering columns, and bucketing columns in the table. * `columns` - Configuration block for columns in the table. See [`columns`](#columns) below. * `compressed` - Whether the data in the table is compressed. diff --git a/website/docs/r/glue_catalog_table.html.markdown b/website/docs/r/glue_catalog_table.html.markdown index 6773b76b049d..878c62049386 100644 --- a/website/docs/r/glue_catalog_table.html.markdown +++ b/website/docs/r/glue_catalog_table.html.markdown @@ -135,6 +135,7 @@ To add an index to an existing table, see the [`glue_partition_index` resource]( ### storage_descriptor +* `additional_locations` - (Optional) List of locations that point to the path where a Delta table is located. * `bucket_columns` - (Optional) List of reducer grouping columns, clustering columns, and bucketing columns in the table. * `columns` - (Optional) Configuration block for columns in the table. See [`columns`](#columns) below. * `compressed` - (Optional) Whether the data in the table is compressed.