@@ -788,7 +788,92 @@ func TestAccDynamoDBTable_streamSpecification(t *testing.T) {
788
788
Check : resource .ComposeAggregateTestCheckFunc (
789
789
testAccCheckInitialTableExists (resourceName , & conf ),
790
790
resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "false" ),
791
- resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "" ),
791
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "KEYS_ONLY" ),
792
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
793
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
794
+ ),
795
+ },
796
+ },
797
+ })
798
+ }
799
+
800
+ func TestAccDynamoDBTable_streamSpecificationDiffs (t * testing.T ) {
801
+ var conf dynamodb.DescribeTableOutput
802
+ resourceName := "aws_dynamodb_table.test"
803
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
804
+
805
+ resource .ParallelTest (t , resource.TestCase {
806
+ PreCheck : func () { acctest .PreCheck (t ) },
807
+ ErrorCheck : acctest .ErrorCheck (t , dynamodb .EndpointsID ),
808
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
809
+ CheckDestroy : testAccCheckTableDestroy ,
810
+ Steps : []resource.TestStep {
811
+ {
812
+ Config : testAccTableConfig_streamSpecification (rName , true , "KEYS_ONLY" ),
813
+ Check : resource .ComposeAggregateTestCheckFunc (
814
+ testAccCheckInitialTableExists (resourceName , & conf ),
815
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "true" ),
816
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "KEYS_ONLY" ),
817
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
818
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
819
+ ),
820
+ },
821
+ {
822
+ Config : testAccTableConfig_streamSpecification (rName , true , "NEW_IMAGE" ),
823
+ Check : resource .ComposeAggregateTestCheckFunc (
824
+ testAccCheckInitialTableExists (resourceName , & conf ),
825
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "true" ),
826
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "NEW_IMAGE" ),
827
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
828
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
829
+ ),
830
+ },
831
+ {
832
+ Config : testAccTableConfig_streamSpecification (rName , false , "NEW_IMAGE" ),
833
+ Check : resource .ComposeAggregateTestCheckFunc (
834
+ testAccCheckInitialTableExists (resourceName , & conf ),
835
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "false" ),
836
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "NEW_IMAGE" ),
837
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
838
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
839
+ ),
840
+ },
841
+ {
842
+ Config : testAccTableConfig_streamSpecification (rName , false , "KEYS_ONLY" ),
843
+ Check : resource .ComposeAggregateTestCheckFunc (
844
+ testAccCheckInitialTableExists (resourceName , & conf ),
845
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "false" ),
846
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "KEYS_ONLY" ),
847
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
848
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
849
+ ),
850
+ },
851
+ {
852
+ Config : testAccTableConfig_streamSpecification (rName , false , "null" ),
853
+ Check : resource .ComposeAggregateTestCheckFunc (
854
+ testAccCheckInitialTableExists (resourceName , & conf ),
855
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "false" ),
856
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "KEYS_ONLY" ),
857
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
858
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
859
+ ),
860
+ },
861
+ {
862
+ Config : testAccTableConfig_streamSpecification (rName , true , "KEYS_ONLY" ),
863
+ Check : resource .ComposeAggregateTestCheckFunc (
864
+ testAccCheckInitialTableExists (resourceName , & conf ),
865
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "true" ),
866
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "KEYS_ONLY" ),
867
+ acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
868
+ resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
869
+ ),
870
+ },
871
+ {
872
+ Config : testAccTableConfig_streamSpecification (rName , true , "KEYS_ONLY" ),
873
+ Check : resource .ComposeAggregateTestCheckFunc (
874
+ testAccCheckInitialTableExists (resourceName , & conf ),
875
+ resource .TestCheckResourceAttr (resourceName , "stream_enabled" , "true" ),
876
+ resource .TestCheckResourceAttr (resourceName , "stream_view_type" , "KEYS_ONLY" ),
792
877
acctest .MatchResourceAttrRegionalARN (resourceName , "stream_arn" , "dynamodb" , regexp .MustCompile (fmt .Sprintf ("table/%s/stream" , rName ))),
793
878
resource .TestCheckResourceAttrSet (resourceName , "stream_label" ),
794
879
),
@@ -2442,6 +2527,9 @@ resource "aws_dynamodb_table" "test" {
2442
2527
}
2443
2528
2444
2529
func testAccTableConfig_streamSpecification (rName string , enabled bool , viewType string ) string {
2530
+ if viewType != "null" {
2531
+ viewType = fmt .Sprintf (`"%s"` , viewType )
2532
+ }
2445
2533
return fmt .Sprintf (`
2446
2534
resource "aws_dynamodb_table" "test" {
2447
2535
name = %[1]q
@@ -2455,7 +2543,7 @@ resource "aws_dynamodb_table" "test" {
2455
2543
}
2456
2544
2457
2545
stream_enabled = %[2]t
2458
- stream_view_type = %[3]q
2546
+ stream_view_type = %[3]s
2459
2547
}
2460
2548
` , rName , enabled , viewType )
2461
2549
}
0 commit comments