@@ -284,9 +284,9 @@ func resourceApplication() *schema.Resource {
284
284
Elem : & schema.Resource {
285
285
Schema : map [string ]* schema.Schema {
286
286
"application_restore_type" : {
287
+ // NOTE: Set as required in Cloudformation: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-kinesisanalyticsv2-application-applicationrestoreconfiguration.html
287
288
Type : schema .TypeString ,
288
- Optional : true ,
289
- Computed : true ,
289
+ Required : true ,
290
290
ValidateDiagFunc : enum .Validate [awstypes.ApplicationRestoreType ](),
291
291
},
292
292
"snapshot_name" : {
@@ -1283,17 +1283,29 @@ func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta
1283
1283
}
1284
1284
}
1285
1285
1286
- if d . HasChange ("application_configuration.0.run_configuration" ) {
1286
+ if runConfig := d . Get ("application_configuration.0.run_configuration" ).([] any ); len ( runConfig ) > 0 {
1287
1287
application , err := findApplicationDetailByName (ctx , conn , applicationName )
1288
1288
1289
1289
if err != nil {
1290
1290
return sdkdiag .AppendErrorf (diags , "reading Kinesis Analytics v2 Application (%s): %s" , applicationName , err )
1291
1291
}
1292
1292
1293
1293
if actual , expected := application .ApplicationStatus , awstypes .ApplicationStatusRunning ; actual == expected {
1294
- input .RunConfigurationUpdate = expandRunConfigurationUpdate (d .Get ("application_configuration.0.run_configuration" ).([]any ))
1294
+ var needsRunConfigUpdate bool
1295
+ // NOTE: Always apply application_restore_configuration if set (prevents dangerous defaults)
1296
+ if restoreConfig := d .Get ("application_configuration.0.run_configuration.0.application_restore_configuration" ).([]any ); len (restoreConfig ) > 0 && restoreConfig [0 ] != nil {
1297
+ needsRunConfigUpdate = true
1298
+ }
1295
1299
1296
- updateApplication = true
1300
+ // Catch any other run config changes
1301
+ if d .HasChange ("application_configuration.0.run_configuration" ) {
1302
+ needsRunConfigUpdate = true
1303
+ }
1304
+
1305
+ if needsRunConfigUpdate {
1306
+ input .RunConfigurationUpdate = expandRunConfigurationUpdate (d .Get ("application_configuration.0.run_configuration" ).([]any ))
1307
+ updateApplication = true
1308
+ }
1297
1309
}
1298
1310
}
1299
1311
0 commit comments