in source/packages/services/installer/src/commands/modules/service/organizationManager.ts [93:222]
public async prompts(answers: Answers): Promise<Answers> {
delete answers.organizationManager?.redeploy;
let updatedAnswers: Answers = await inquirer.prompt(
[redeployIfAlreadyExistsPrompt(this.name, this.stackName)],
answers
);
if ((updatedAnswers.organizationManager?.redeploy ?? true) === false) {
return updatedAnswers;
}
const allRegions = await this.getAWSRegions();
updatedAnswers = await inquirer.prompt(
[
chooseS3BucketPrompt(
'Provide the name of an existing S3 bucket used by control tower customization:',
'organizationManager.controlTowerBucket',
answers.organizationManager?.controlTowerBucket
),
...applicationConfigurationPrompt(this.name, answers, [
{
question: 'Enable delete ou(s) feature?',
propertyName: 'createOUsEnabled',
defaultConfiguration: false,
},
{
question: 'Enable create ou(s) feature?',
propertyName: 'deleteOUsEnabled',
defaultConfiguration: false,
},
{
question: 'Enable create account(s) feature?',
propertyName: 'createAccountsEnabled',
defaultConfiguration: false,
},
{
question: 'Enable delete account(s) feature?',
propertyName: 'deleteAccountsEnabled',
defaultConfiguration: false,
},
]),
{
message:
'Select list of region supported by Organization Manager (this will be used to create an artifact bucket in the selected regions to store the artifacts referenced by CloudFormation StackSets multi region deployment):',
type: 'checkbox',
name: 'organizationManager.supportedRegions',
choices: allRegions,
default: answers.organizationManager?.supportedRegions,
pageSize: 20,
loop: false,
askAnswered: true,
validate(answer: string[]) {
if (answer?.length === 0) {
return 'You must choose at least one region to enable.';
}
return true;
},
},
{
message: `Enter the bucket prefix (this will be used when creating bucket in regions that are supported by Organization Manager):`,
type: 'input',
name: 'organizationManager.artifactBucketPrefix',
default: answers.organizationManager?.artifactBucketPrefix,
askAnswered: true,
validate(answer: string) {
if (answer?.length === 0) {
return 'You must enter the bucket prefix.';
}
return true;
},
},
{
message: `Enter AWS Organization Id:`,
type: 'input',
name: 'organizationManager.organizationId',
default: answers.organizationManager?.organizationId,
askAnswered: true,
validate(answer: string) {
if (answer?.length === 0) {
return 'You must enter the AWS Organization Id.';
}
return true;
},
},
...customDomainPrompt(this.name, answers),
{
message: `Enter the IAM role that can be assumed from Management Account:`,
type: 'input',
name: 'organizationManager.managementAccountRole',
default: answers.organizationManager?.managementAccountRole,
askAnswered: true,
when(answers: Answers) {
return (
answers.organizationManager.deleteAccountsEnabled ||
answers.organizationManager.createAccountsEnabled ||
answers.organizationManager.deleteOUsEnabled ||
answers.organizationManager.createOUsEnabled
);
},
validate(answer: string) {
if (answer?.length === 0) {
return 'You must enter the IAM role.';
}
return true;
},
},
{
message: `Enter OU for suspended account:`,
type: 'input',
name: 'organizationManager.suspendedOu',
default: answers.organizationManager?.suspendedOU,
askAnswered: true,
when(answers: Answers) {
return answers.organizationManager.deleteAccountsEnabled;
},
validate(answer: string) {
if (answer?.length === 0) {
return 'You must enter the OU for suspended account.';
}
return true;
},
},
],
updatedAnswers
);
return updatedAnswers;
}