@@ -902,6 +902,40 @@ func TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes(t *testing.T) {
902
902
})
903
903
}
904
904
905
+ // Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/15115
906
+ func TestAccAWSDynamoDbTable_lsiNonKeyAttributes (t * testing.T ) {
907
+ var conf dynamodb.DescribeTableOutput
908
+ resourceName := "aws_dynamodb_table.test"
909
+ rName := acctest .RandomWithPrefix ("tf-acc-test" )
910
+
911
+ resource .ParallelTest (t , resource.TestCase {
912
+ PreCheck : func () { testAccPreCheck (t ) },
913
+ Providers : testAccProviders ,
914
+ CheckDestroy : testAccCheckAWSDynamoDbTableDestroy ,
915
+ Steps : []resource.TestStep {
916
+ {
917
+ Config : testAccAWSDynamoDbConfigLsiNonKeyAttributes (rName ),
918
+ Check : resource .ComposeTestCheckFunc (
919
+ testAccCheckInitialAWSDynamoDbTableExists (resourceName , & conf ),
920
+ resource .TestCheckResourceAttr (resourceName , "local_secondary_index.#" , "1" ),
921
+ tfawsresource .TestCheckTypeSetElemNestedAttrs (resourceName , "local_secondary_index.*" , map [string ]string {
922
+ "name" : "TestTableLSI" ,
923
+ "non_key_attributes.#" : "1" ,
924
+ "non_key_attributes.0" : "TestNonKeyAttribute" ,
925
+ "projection_type" : "INCLUDE" ,
926
+ "range_key" : "TestLSIRangeKey" ,
927
+ }),
928
+ ),
929
+ },
930
+ {
931
+ ResourceName : resourceName ,
932
+ ImportState : true ,
933
+ ImportStateVerify : true ,
934
+ },
935
+ },
936
+ })
937
+ }
938
+
905
939
// https://github.com/terraform-providers/terraform-provider-aws/issues/566
906
940
func TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (t * testing.T ) {
907
941
var conf dynamodb.DescribeTableOutput
@@ -2084,6 +2118,40 @@ resource "aws_dynamodb_table" "test" {
2084
2118
` , name , attributes )
2085
2119
}
2086
2120
2121
+ func testAccAWSDynamoDbConfigLsiNonKeyAttributes (name string ) string {
2122
+ return fmt .Sprintf (`
2123
+ resource "aws_dynamodb_table" "test" {
2124
+ name = "%s"
2125
+ hash_key = "TestTableHashKey"
2126
+ range_key = "TestTableRangeKey"
2127
+ write_capacity = 1
2128
+ read_capacity = 1
2129
+
2130
+ attribute {
2131
+ name = "TestTableHashKey"
2132
+ type = "S"
2133
+ }
2134
+
2135
+ attribute {
2136
+ name = "TestTableRangeKey"
2137
+ type = "S"
2138
+ }
2139
+
2140
+ attribute {
2141
+ name = "TestLSIRangeKey"
2142
+ type = "N"
2143
+ }
2144
+
2145
+ local_secondary_index {
2146
+ name = "TestTableLSI"
2147
+ range_key = "TestLSIRangeKey"
2148
+ projection_type = "INCLUDE"
2149
+ non_key_attributes = ["TestNonKeyAttribute"]
2150
+ }
2151
+ }
2152
+ ` , name )
2153
+ }
2154
+
2087
2155
func testAccAWSDynamoDbConfigTimeToLive (rName string , ttlEnabled bool ) string {
2088
2156
return fmt .Sprintf (`
2089
2157
resource "aws_dynamodb_table" "test" {
0 commit comments