@@ -386,7 +386,7 @@ const countryQuestions = [
386386 }
387387]
388388
389- const infrastructureQuestions = [
389+ const diskQuestions = [
390390 {
391391 name : 'diskSpace' ,
392392 type : 'text' as const ,
@@ -397,8 +397,10 @@ const infrastructureQuestions = [
397397 validate : notEmpty ,
398398 valueLabel : 'DISK_SPACE' ,
399399 initial : process . env . DISK_SPACE || '200g' ,
400- scope : 'ENVIRONMENT' as const
400+ scope : 'ENVIRONMENT' as const ,
401401 } ,
402+ ]
403+ const infrastructureQuestions = [
402404 {
403405 name : 'domain' ,
404406 type : 'text' as const ,
@@ -887,7 +889,7 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
887889 ...existingRepositoryVariable ,
888890 ...existingEnvironmentSecrets
889891 ]
890-
892+ var enableEncryption = true
891893 if (
892894 existingEnvironmentVariables . length > 0 ||
893895 existingEnvironmentSecrets . length > 0
@@ -967,7 +969,31 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
967969 )
968970 }
969971 } else {
970- log ( '\n' , kleur . bold ( ) . underline ( 'Server setup' ) )
972+ log ( '\n' , kleur . bold ( ) . underline ( 'Server setup' ) , '\n' )
973+ const encryption_key_defined = findExistingValue (
974+ 'ENCRYPTION_KEY' ,
975+ 'SECRET' ,
976+ 'ENVIRONMENT' ,
977+ existingValues
978+ )
979+
980+ if ( ! encryption_key_defined ) {
981+ const answers_enable_encryption = await prompts (
982+ [
983+ {
984+ name : 'enableEncryption' ,
985+ type : 'confirm' as const ,
986+ message : 'Do you want to enable disk encryption?' ,
987+ scope : 'ENVIRONMENT' as const ,
988+ initial : Boolean ( process . env . ENABLE_ENCRYPTION )
989+ }
990+ ] . map ( questionToPrompt )
991+ )
992+ enableEncryption = answers_enable_encryption . enableEncryption
993+ }
994+ if ( enableEncryption ) {
995+ await promptAndStoreAnswer ( environment , diskQuestions , existingValues )
996+ }
971997 const { domain } = await promptAndStoreAnswer (
972998 environment ,
973999 infrastructureQuestions ,
@@ -1101,6 +1127,26 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
11011127 }
11021128 ]
11031129
1130+ if ( enableEncryption ) {
1131+ derivedUpdates . push ( {
1132+ name : 'ENCRYPTION_KEY' ,
1133+ type : 'SECRET' as const ,
1134+ didExist : findExistingValue (
1135+ 'ENCRYPTION_KEY' ,
1136+ 'SECRET' ,
1137+ 'ENVIRONMENT' ,
1138+ existingValues
1139+ ) ,
1140+ value : findExistingOrDefine (
1141+ 'ENCRYPTION_KEY' ,
1142+ 'SECRET' ,
1143+ 'ENVIRONMENT' ,
1144+ generateLongPassword ( )
1145+ ) ,
1146+ scope : 'ENVIRONMENT' as const
1147+ } )
1148+ }
1149+
11041150 if ( [ 'production' , 'staging' ] . includes ( environment ) ) {
11051151 derivedUpdates . push ( {
11061152 name : 'BACKUP_ENCRYPTION_PASSPHRASE' ,
@@ -1275,23 +1321,6 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
12751321 ) ,
12761322 scope : 'ENVIRONMENT' as const
12771323 } ,
1278- {
1279- name : 'ENCRYPTION_KEY' ,
1280- type : 'SECRET' as const ,
1281- didExist : findExistingValue (
1282- 'ENCRYPTION_KEY' ,
1283- 'SECRET' ,
1284- 'ENVIRONMENT' ,
1285- existingValues
1286- ) ,
1287- value : findExistingOrDefine (
1288- 'ENCRYPTION_KEY' ,
1289- 'SECRET' ,
1290- 'ENVIRONMENT' ,
1291- generateLongPassword ( )
1292- ) ,
1293- scope : 'ENVIRONMENT' as const
1294- } ,
12951324 {
12961325 type : 'VARIABLE' as const ,
12971326 name : 'ACTIVATE_USERS' ,
0 commit comments