Skip to content

Commit

Permalink
resource/aws_glue_partition: Add nil check for schema_reference and…
Browse files Browse the repository at this point in the history
… `partition_values` validation (#17702)

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSGlueCatalogTable_basic (31.10s)
--- PASS: TestAccAWSGlueCatalogTable_columnParameters (33.94s)
--- PASS: TestAccAWSGlueCatalogTable_disappears (30.13s)
--- PASS: TestAccAWSGlueCatalogTable_disappears_database (24.49s)
--- PASS: TestAccAWSGlueCatalogTable_full (35.08s)
--- PASS: TestAccAWSGlueCatalogTable_partitionIndexesMultiple (35.00s)
--- PASS: TestAccAWSGlueCatalogTable_partitionIndexesSingle (34.57s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_EmptyConfigurationBlock (31.82s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_schemaReference (38.78s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_schemaReferenceArn (39.47s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_SerDeInfo_EmptyConfigurationBlock (31.91s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_SerDeInfo_UpdateValues (43.66s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_SkewedInfo_EmptyConfigurationBlock (31.99s)
--- PASS: TestAccAWSGlueCatalogTable_update_addValues (45.27s)
--- PASS: TestAccAWSGlueCatalogTable_update_replaceValues (46.23s)

--- PASS: TestAccAWSGluePartition_basic (35.44s)
--- PASS: TestAccAWSGluePartition_disappears (31.50s)
--- PASS: TestAccAWSGluePartition_disappears_table (30.91s)
--- PASS: TestAccAWSGluePartition_multipleValues (35.76s)
--- PASS: TestAccAWSGluePartition_parameters (56.26s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- FAIL: TestAccAWSGlueCatalogTable_StorageDescriptor_schemaReference (15.54s) # #17449
--- FAIL: TestAccAWSGlueCatalogTable_StorageDescriptor_schemaReferenceArn (14.85s) # #17449
--- PASS: TestAccAWSGlueCatalogTable_basic (32.74s)
--- PASS: TestAccAWSGlueCatalogTable_columnParameters (34.11s)
--- PASS: TestAccAWSGlueCatalogTable_disappears (28.84s)
--- PASS: TestAccAWSGlueCatalogTable_disappears_database (24.42s)
--- PASS: TestAccAWSGlueCatalogTable_full (31.56s)
--- PASS: TestAccAWSGlueCatalogTable_partitionIndexesMultiple (32.82s)
--- PASS: TestAccAWSGlueCatalogTable_partitionIndexesSingle (32.55s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_EmptyConfigurationBlock (30.14s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_SerDeInfo_EmptyConfigurationBlock (30.73s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_SerDeInfo_UpdateValues (47.27s)
--- PASS: TestAccAWSGlueCatalogTable_StorageDescriptor_SkewedInfo_EmptyConfigurationBlock (30.30s)
--- PASS: TestAccAWSGlueCatalogTable_update_addValues (48.12s)
--- PASS: TestAccAWSGlueCatalogTable_update_replaceValues (47.88s)

--- PASS: TestAccAWSGluePartition_basic (34.71s)
--- PASS: TestAccAWSGluePartition_disappears (31.71s)
--- PASS: TestAccAWSGluePartition_disappears_table (30.66s)
--- PASS: TestAccAWSGluePartition_multipleValues (35.11s)
--- PASS: TestAccAWSGluePartition_parameters (64.63s)
```
  • Loading branch information
DrFaust92 authored Feb 19, 2021
1 parent 3425931 commit 32bc5fd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changelog/17702.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:bug
resource/aws_glue_catalog_table: Prevent `schema_reference` attribute error
```

```release-note:enhancement
resource/aws_glue_partition: Add plan time validation for `partition_values`
```
5 changes: 4 additions & 1 deletion aws/resource_aws_glue_catalog_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,12 @@ func flattenGlueStorageDescriptor(s *glue.StorageDescriptor) []map[string]interf
storageDescriptor["sort_columns"] = flattenGlueOrders(s.SortColumns)
storageDescriptor["parameters"] = aws.StringValueMap(s.Parameters)
storageDescriptor["skewed_info"] = flattenGlueSkewedInfo(s.SkewedInfo)
storageDescriptor["schema_reference"] = flattenGlueTableSchemaReference(s.SchemaReference)
storageDescriptor["stored_as_sub_directories"] = aws.BoolValue(s.StoredAsSubDirectories)

if s.SchemaReference != nil {
storageDescriptor["schema_reference"] = flattenGlueTableSchemaReference(s.SchemaReference)
}

storageDescriptors[0] = storageDescriptor

return storageDescriptors
Expand Down
5 changes: 4 additions & 1 deletion aws/resource_aws_glue_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func resourceAwsGluePartition() *schema.Resource {
Type: schema.TypeList,
Required: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringLenBetween(1, 1024),
},
},
"storage_descriptor": {
Type: schema.TypeList,
Expand Down
22 changes: 22 additions & 0 deletions aws/resource_aws_glue_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ func TestAccAWSGluePartition_disappears(t *testing.T) {
})
}

func TestAccAWSGluePartition_disappears_table(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
parValue := acctest.RandString(10)
resourceName := "aws_glue_partition.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckGluePartitionDestroy,
Steps: []resource.TestStep{
{
Config: testAccGluePartitionBasicConfig(rName, parValue),
Check: resource.ComposeTestCheckFunc(
testAccCheckGluePartitionExists(resourceName),
testAccCheckResourceDisappears(testAccProvider, resourceAwsGlueCatalogTable(), "aws_glue_catalog_table.test"),
),
ExpectNonEmptyPlan: true,
},
},
})
}

func testAccCheckGluePartitionDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).glueconn

Expand Down

0 comments on commit 32bc5fd

Please sign in to comment.