@@ -1272,6 +1272,51 @@ func TestAccKinesisAnalyticsV2Application_FlinkApplication_restoreFromSnapshot(t
1272
1272
})
1273
1273
}
1274
1274
1275
+ func TestAccKinesisAnalyticsV2Application_FlinkApplication_snapshotToggleRestoreTypeBug (t * testing.T ) {
1276
+ ctx := acctest .Context (t )
1277
+ var v awstypes.ApplicationDetail
1278
+ resourceName := "aws_kinesisanalyticsv2_application.test"
1279
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
1280
+
1281
+ resource .ParallelTest (t , resource.TestCase {
1282
+ PreCheck : func () { acctest .PreCheck (ctx , t ); testAccPreCheck (ctx , t ) },
1283
+ ErrorCheck : acctest .ErrorCheck (t , names .KinesisAnalyticsV2ServiceID ),
1284
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
1285
+ CheckDestroy : testAccCheckApplicationDestroy (ctx ),
1286
+ Steps : []resource.TestStep {
1287
+ // Step 1: Create application with snapshots enabled and SKIP_RESTORE_FROM_SNAPSHOT
1288
+ {
1289
+ Config : testAccApplicationConfig_snapshotToggleBug (rName , true ),
1290
+ Check : resource .ComposeTestCheckFunc (
1291
+ testAccCheckApplicationExists (ctx , resourceName , & v ),
1292
+ resource .TestCheckResourceAttr (resourceName , "application_configuration.0.application_snapshot_configuration.0.snapshots_enabled" , acctest .CtTrue ),
1293
+ resource .TestCheckResourceAttr (resourceName , "application_configuration.0.run_configuration.0.application_restore_configuration.0.application_restore_type" , "SKIP_RESTORE_FROM_SNAPSHOT" ),
1294
+ ),
1295
+ },
1296
+ // Step 2: Disable snapshots but maintain SKIP_RESTORE_FROM_SNAPSHOT
1297
+ {
1298
+ Config : testAccApplicationConfig_snapshotToggleBug (rName , false ),
1299
+ Check : resource .ComposeTestCheckFunc (
1300
+ testAccCheckApplicationExists (ctx , resourceName , & v ),
1301
+ resource .TestCheckResourceAttr (resourceName , "application_configuration.0.application_snapshot_configuration.0.snapshots_enabled" , acctest .CtFalse ),
1302
+ resource .TestCheckResourceAttr (resourceName , "application_configuration.0.run_configuration.0.application_restore_configuration.0.application_restore_type" , "SKIP_RESTORE_FROM_SNAPSHOT" ),
1303
+ ),
1304
+ },
1305
+ // Step 3: Re-enable snapshots - application_restore_type should remain SKIP_RESTORE_FROM_SNAPSHOT
1306
+ {
1307
+ Config : testAccApplicationConfig_snapshotToggleBug (rName , true ),
1308
+ Check : resource .ComposeTestCheckFunc (
1309
+ testAccCheckApplicationExists (ctx , resourceName , & v ),
1310
+ resource .TestCheckResourceAttr (resourceName , "application_configuration.0.application_snapshot_configuration.0.snapshots_enabled" , acctest .CtTrue ),
1311
+ // This is the critical check - the restore type should remain SKIP_RESTORE_FROM_SNAPSHOT
1312
+ // but the bug causes it to default to restore from latest snapshot
1313
+ resource .TestCheckResourceAttr (resourceName , "application_configuration.0.run_configuration.0.application_restore_configuration.0.application_restore_type" , "SKIP_RESTORE_FROM_SNAPSHOT" ),
1314
+ ),
1315
+ },
1316
+ },
1317
+ })
1318
+ }
1319
+
1275
1320
func TestAccKinesisAnalyticsV2Application_FlinkApplicationStartApplication_onCreate (t * testing.T ) {
1276
1321
ctx := acctest .Context (t )
1277
1322
var v awstypes.ApplicationDetail
@@ -5750,3 +5795,83 @@ resource "aws_kinesisanalyticsv2_application" "test" {
5750
5795
}
5751
5796
` , rName ))
5752
5797
}
5798
+
5799
+ func testAccApplicationConfig_snapshotToggleBug (rName string , snapshotsEnabled bool ) string {
5800
+ return acctest .ConfigCompose (
5801
+ testAccApplicationConfig_baseServiceExecutionIAMRole (rName ),
5802
+ testAccApplicationConfig_baseFlinkApplication (rName ),
5803
+ fmt .Sprintf (`
5804
+ resource "aws_kinesisanalyticsv2_application" "test" {
5805
+ name = %[1]q
5806
+ runtime_environment = "FLINK-1_20"
5807
+ service_execution_role = aws_iam_role.test[0].arn
5808
+ start_application = true
5809
+
5810
+ application_configuration {
5811
+ application_code_configuration {
5812
+ code_content {
5813
+ s3_content_location {
5814
+ bucket_arn = aws_s3_bucket.test.arn
5815
+ file_key = aws_s3_object.test[0].key
5816
+ object_version = aws_s3_object.test[0].version_id
5817
+ }
5818
+ }
5819
+
5820
+ code_content_type = "ZIPFILE"
5821
+ }
5822
+
5823
+ application_snapshot_configuration {
5824
+ snapshots_enabled = %[2]t
5825
+ }
5826
+
5827
+ environment_properties {
5828
+ property_group {
5829
+ property_group_id = "InputStream0"
5830
+
5831
+ property_map = {
5832
+ "aws.region" = data.aws_region.current.region
5833
+ "stream.name" = aws_kinesis_stream.input.name
5834
+ }
5835
+ }
5836
+
5837
+ property_group {
5838
+ property_group_id = "OutputStream0"
5839
+
5840
+ property_map = {
5841
+ "aws.region" = data.aws_region.current.region
5842
+ "stream.name" = aws_kinesis_stream.output.name
5843
+ }
5844
+ }
5845
+ }
5846
+
5847
+ flink_application_configuration {
5848
+ checkpoint_configuration {
5849
+ configuration_type = "DEFAULT"
5850
+ }
5851
+
5852
+ monitoring_configuration {
5853
+ configuration_type = "CUSTOM"
5854
+ log_level = "DEBUG"
5855
+ metrics_level = "TASK"
5856
+ }
5857
+
5858
+ parallelism_configuration {
5859
+ auto_scaling_enabled = true
5860
+ configuration_type = "CUSTOM"
5861
+ parallelism = 1
5862
+ parallelism_per_kpu = 1
5863
+ }
5864
+ }
5865
+
5866
+ run_configuration {
5867
+ application_restore_configuration {
5868
+ application_restore_type = "SKIP_RESTORE_FROM_SNAPSHOT"
5869
+ }
5870
+ flink_run_configuration {
5871
+ allow_non_restored_state = false
5872
+ }
5873
+ }
5874
+ }
5875
+ }
5876
+ ` , rName , snapshotsEnabled ))
5877
+ }
0 commit comments