Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- **Remove Unused Scopes**: Removed `RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS` and `RECORD_EXPORT_RECORDS` scopes from `REGISTRATION_AGENT`, `LOCAL_REGISTRAR` and `NATIONAL_REGISTRAR`

### Improvements

- Make encryption step optional [#1123](https://github.com/opencrvs/opencrvs-countryconfig/pull/1123)

## 1.9.0

### New features
Expand Down
73 changes: 52 additions & 21 deletions infrastructure/environments/setup-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ const countryQuestions = [
}
]

const infrastructureQuestions = [
const diskQuestions = [
{
name: 'diskSpace',
type: 'text' as const,
Expand All @@ -397,8 +397,10 @@ const infrastructureQuestions = [
validate: notEmpty,
valueLabel: 'DISK_SPACE',
initial: process.env.DISK_SPACE || '200g',
scope: 'ENVIRONMENT' as const
scope: 'ENVIRONMENT' as const,
},
]
const infrastructureQuestions = [
{
name: 'domain',
type: 'text' as const,
Expand Down Expand Up @@ -780,6 +782,7 @@ ALL_QUESTIONS.push(
...dockerhubQuestions,
...sshQuestions,
...sshKeyQuestions,
...diskQuestions,
...infrastructureQuestions,
...countryQuestions,
...databaseAndMonitoringQuestions,
Expand Down Expand Up @@ -887,7 +890,7 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
...existingRepositoryVariable,
...existingEnvironmentSecrets
]

let enableEncryption = true
if (
existingEnvironmentVariables.length > 0 ||
existingEnvironmentSecrets.length > 0
Expand Down Expand Up @@ -967,7 +970,32 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
)
}
} else {
log('\n', kleur.bold().underline('Server setup'))
log('\n', kleur.bold().underline('Server setup'), '\n')
const encryption_key_defined = findExistingValue(
'ENCRYPTION_KEY',
'SECRET',
'ENVIRONMENT',
existingValues
)

if (!encryption_key_defined) {
const answers_enable_encryption = await prompts(
[
{
name: 'enableEncryption',
type: 'confirm' as const,
message: 'Do you want to enable disk encryption?',
scope: 'ENVIRONMENT' as const,
initial: Boolean(process.env.ENABLE_ENCRYPTION)
}
].map(questionToPrompt)
)
enableEncryption = answers_enable_encryption.enableEncryption
Comment on lines +981 to +993
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: If ENCRYPTION_KEY already exists, enableEncryption stays true but the user is never asked about disk space. This means encryption mode is inferred from the existence of ENCRYPTION_KEY rather than being explicitly controlled. Consider checking for both ENCRYPTION_KEY and DISK_SPACE to determine if encryption was previously enabled, or prompt the user for clarity.

}
if (enableEncryption) {
console.log('\n', kleur.bold().green('✔'), kleur.bold().yellow(' Disk encryption is enabled'))
await promptAndStoreAnswer(environment, diskQuestions, existingValues)
}
const { domain } = await promptAndStoreAnswer(
environment,
infrastructureQuestions,
Expand Down Expand Up @@ -1101,6 +1129,26 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
}
]

if (enableEncryption){
derivedUpdates.push({
name: 'ENCRYPTION_KEY',
type: 'SECRET' as const,
didExist: findExistingValue(
'ENCRYPTION_KEY',
'SECRET',
'ENVIRONMENT',
existingValues
),
value: findExistingOrDefine(
'ENCRYPTION_KEY',
'SECRET',
'ENVIRONMENT',
generateLongPassword()
),
scope: 'ENVIRONMENT' as const
})
}

if (['production', 'staging'].includes(environment)) {
derivedUpdates.push({
name: 'BACKUP_ENCRYPTION_PASSPHRASE',
Expand Down Expand Up @@ -1275,23 +1323,6 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
),
scope: 'ENVIRONMENT' as const
},
{
name: 'ENCRYPTION_KEY',
type: 'SECRET' as const,
didExist: findExistingValue(
'ENCRYPTION_KEY',
'SECRET',
'ENVIRONMENT',
existingValues
),
value: findExistingOrDefine(
'ENCRYPTION_KEY',
'SECRET',
'ENVIRONMENT',
generateLongPassword()
),
scope: 'ENVIRONMENT' as const
},
{
type: 'VARIABLE' as const,
name: 'ACTIVATE_USERS',
Expand Down
Loading