@@ -142,6 +142,7 @@ public void updateSettings(
142142 validateRefreshIntervalSettings (normalizedSettings , clusterService .getClusterSettings ());
143143 validateTranslogDurabilitySettings (normalizedSettings , clusterService .getClusterSettings (), clusterService .getSettings ());
144144 validateIndexTotalPrimaryShardsPerNodeSetting (normalizedSettings , clusterService );
145+ validateCryptoStoreSettings (normalizedSettings , request .indices (), clusterService .state ());
145146 final int defaultReplicaCount = clusterService .getClusterSettings ().get (Metadata .DEFAULT_REPLICA_COUNT_SETTING );
146147
147148 Settings .Builder settingsForClosedIndices = Settings .builder ();
@@ -589,4 +590,32 @@ public static void validateIndexTotalPrimaryShardsPerNodeSetting(Settings indexS
589590 );
590591 }
591592 }
593+
594+ /**
595+ * Validates crypto store settings are immutable after index creation.
596+ */
597+ public static void validateCryptoStoreSettings (Settings indexSettings , Index [] indices , ClusterState clusterState ) {
598+ final String [] restrictedCryptoSettings = {
599+ "index.store.crypto.key_provider" ,
600+ "index.store.crypto.kms.key_arn" ,
601+ "index.store.crypto.kms.encryption_context" };
602+
603+ // Crypto settings are completely immutable - reject any attempt to modify them
604+ for (String settingKey : restrictedCryptoSettings ) {
605+ if (indexSettings .keySet ().contains (settingKey )) {
606+ throw new IllegalArgumentException ("Cannot update [" + settingKey + "] - crypto settings are immutable" );
607+ }
608+ }
609+
610+ // Validate store type changes
611+ String newStoreType = indexSettings .get ("index.store.type" );
612+ if ("cryptofs" .equals (newStoreType )) {
613+ for (Index index : indices ) {
614+ String currentStoreType = clusterState .metadata ().getIndexSafe (index ).getSettings ().get ("index.store.type" , "" );
615+ if (!"cryptofs" .equals (currentStoreType )) {
616+ throw new IllegalArgumentException ("Cannot change store type to 'cryptofs' for index [" + index .getName () + "]" );
617+ }
618+ }
619+ }
620+ }
592621}
0 commit comments