diff --git a/aws/resource_aws_dynamodb_table.go b/aws/resource_aws_dynamodb_table.go index 83e71b6b9a3..f9c2e77d514 100644 --- a/aws/resource_aws_dynamodb_table.go +++ b/aws/resource_aws_dynamodb_table.go @@ -156,18 +156,22 @@ func resourceAwsDynamoDbTable() *schema.Resource { "name": { Type: schema.TypeString, Required: true, + ForceNew: true, }, "range_key": { Type: schema.TypeString, Required: true, + ForceNew: true, }, "projection_type": { Type: schema.TypeString, Required: true, + ForceNew: true, }, "non_key_attributes": { Type: schema.TypeList, Optional: true, + ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/aws/resource_aws_dynamodb_table_test.go b/aws/resource_aws_dynamodb_table_test.go index 21b37ad009e..b9d7e391804 100644 --- a/aws/resource_aws_dynamodb_table_test.go +++ b/aws/resource_aws_dynamodb_table_test.go @@ -982,6 +982,37 @@ func TestAccAWSDynamoDbTable_attributeUpdate(t *testing.T) { }) } +func TestAccAWSDynamoDbTable_lsiUpdate(t *testing.T) { + var conf dynamodb.DescribeTableOutput + resourceName := "aws_dynamodb_table.test" + rName := acctest.RandomWithPrefix("TerraformTestTable-") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDynamoDbTableDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSDynamoDbConfigLSI(rName, "lsi-original"), + Check: resource.ComposeTestCheckFunc( + testAccCheckInitialAWSDynamoDbTableExists(resourceName, &conf), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { // Change name of local secondary index + Config: testAccAWSDynamoDbConfigLSI(rName, "lsi-changed"), + Check: resource.ComposeTestCheckFunc( + testAccCheckInitialAWSDynamoDbTableExists(resourceName, &conf), + ), + }, + }, + }) +} + func TestAccAWSDynamoDbTable_attributeUpdateValidation(t *testing.T) { rName := acctest.RandomWithPrefix("TerraformTestTable-") @@ -2083,3 +2114,36 @@ resource "aws_dynamodb_table" "test" { } `, rName, attrName1, attrType1, attrName2, attrType2, hashKey, rangeKey) } + +func testAccAWSDynamoDbConfigLSI(rName, lsiName string) string { + return fmt.Sprintf(` +resource "aws_dynamodb_table" "test" { + name = "%s" + read_capacity = 10 + write_capacity = 10 + hash_key = "staticHashKey" + range_key = "staticRangeKey" + + attribute { + name = "staticHashKey" + type = "S" + } + + attribute { + name = "staticRangeKey" + type = "S" + } + + attribute { + name = "staticLSIRangeKey" + type = "S" + } + + local_secondary_index { + name = "%s" + range_key = "staticLSIRangeKey" + projection_type = "KEYS_ONLY" + } +} +`, rName, lsiName) +}