diff --git a/cli/cmd/generate_aws.go b/cli/cmd/generate_aws.go index c5dc3e49d..62d35704b 100644 --- a/cli/cmd/generate_aws.go +++ b/cli/cmd/generate_aws.go @@ -505,11 +505,18 @@ func askAdvancedAwsOptions(config *aws.GenerateAwsTfConfigurationArgs, extraStat // difficult when the options are dynamic (which they are) // // Only ask about more accounts if consolidated cloudtrail is setup (matching scenarios doc) - options := []string{AdvancedOptCloudTrail, AdvancedOptIamRole} + var options []string + + // Only show Advanced CloudTrail options if CloudTrail integration is set to true + if config.Cloudtrail { + options = append(options, AdvancedOptCloudTrail) + } + if config.ConsolidatedCloudtrail { options = append(options, AdvancedOptAwsAccounts) } - options = append(options, AwsAdvancedOptLocation, AwsAdvancedOptDone) + + options = append(options, AdvancedOptIamRole, AwsAdvancedOptLocation, AwsAdvancedOptDone) if err := SurveyQuestionInteractiveOnly(SurveyQuestionWithValidationArgs{ Prompt: &survey.Select{ Message: "Which options would you like to configure?", diff --git a/cli/cmd/generate_gcp.go b/cli/cmd/generate_gcp.go index 45f1242fe..67002858c 100644 --- a/cli/cmd/generate_gcp.go +++ b/cli/cmd/generate_gcp.go @@ -625,9 +625,14 @@ func askAdvancedOptions(config *gcp.GenerateGcpTfConfigurationArgs, extraState * // Construction of this slice is a bit strange at first look, but the reason for that is because we have to do string // validation to know which option was selected due to how survey works; and doing it by index (also supported) is // difficult when the options are dynamic (which they are) - options := []string{GcpAdvancedOptAuditLog, GcpAdvancedOptExistingServiceAccount, GcpAdvancedOptIntegrationName} + var options []string - options = append(options, GcpAdvancedOptLocation, GcpAdvancedOptDone) + // Only show Advanced AuditLog options if AuditLog integration is set to true + if config.AuditLog { + options = append(options, GcpAdvancedOptAuditLog) + } + + options = append(options, GcpAdvancedOptExistingServiceAccount, GcpAdvancedOptIntegrationName, GcpAdvancedOptLocation, GcpAdvancedOptDone) if err := SurveyQuestionInteractiveOnly(SurveyQuestionWithValidationArgs{ Prompt: &survey.Select{ Message: "Which options would you like to configure?", diff --git a/integration/aws_generation_test.go b/integration/aws_generation_test.go index 6e888d1b7..16d8eb1e7 100644 --- a/integration/aws_generation_test.go +++ b/integration/aws_generation_test.go @@ -319,8 +319,7 @@ func TestGenerationAdvancedOptsConsolidatedWithSubAccounts(t *testing.T) { expectString(t, c, cmd.QuestionAwsAnotherAdvancedOpt) c.SendLine("y") expectString(t, c, cmd.AwsAdvancedOptDone) - c.Send("\x1B[B") // Down arrow twice and enter on the submenu to add subaccounts - c.SendLine("\x1B[B") + c.SendLine("\x1B[B") // Down arrow once and enter on the submenu to add subaccounts expectString(t, c, cmd.QuestionPrimaryAwsAccountProfile) c.SendLine("default") expectString(t, c, cmd.QuestionSubAccountProfileName) @@ -377,8 +376,7 @@ func TestGenerationAdvancedOptsConsolidatedWithSubAccountsPassedByFlag(t *testin expectString(t, c, cmd.QuestionAwsConfigAdvanced) c.SendLine("y") expectString(t, c, cmd.AwsAdvancedOptDone) - c.Send("\x1B[B") // Down arrow twice and enter on the submenu to add subaccounts - c.SendLine("\x1B[B") + c.SendLine("\x1B[B") // Down arrow once and enter on the submenu to add subaccounts expectString(t, c, cmd.QuestionPrimaryAwsAccountProfile) c.SendLine("default") expectString(t, c, fmt.Sprintf(cmd.QuestionSubAccountReplace, "testaccount:us-east-1, testaccount1:us-east-2")) @@ -423,7 +421,7 @@ func TestGenerationAdvancedOptsConsolidatedWithSubAccountsPassedByFlag(t *testin assert.Equal(t, buildTf, tfResult) } -// Test use existing IAM rolej +// Test use existing IAM role func TestGenerationAdvancedOptsUseExistingIAM(t *testing.T) { os.Setenv("LW_NOCACHE", "true") defer os.Setenv("LW_NOCACHE", "")