@@ -15,6 +15,7 @@ import (
1515
1616var (
1717 // Define question text here so they can be reused in testing
18+ QuestionEnableAgentless = "Enable Agentless integration?"
1819 QuestionAwsEnableConfig = "Enable configuration integration?"
1920 QuestionCustomizeConfigName = "Customize Config integration name?"
2021 QuestionConfigName = "Specify name of config integration (optional)"
5758
5859 // select options
5960 AwsAdvancedOptDone = "Done"
61+ AdvancedOptAgentless = "Additional Agentless options (placeholder)"
6062 AdvancedOptCloudTrail = "Additional CloudTrail options"
6163 AdvancedOptIamRole = "Configure Lacework integration with an existing IAM role"
6264 AdvancedOptAwsAccounts = "Add additional AWS Accounts to Lacework"
@@ -137,6 +139,7 @@ See help output for more details on the parameter value(s) required for Terrafor
137139 // Create new struct
138140 data := aws .NewTerraform (
139141 GenerateAwsCommandState .AwsRegion ,
142+ GenerateAwsCommandState .Agentless ,
140143 GenerateAwsCommandState .Config ,
141144 GenerateAwsCommandState .Cloudtrail ,
142145 mods ... )
@@ -315,6 +318,11 @@ func (a *AwsGenerateCommandExtraState) writeCache() {
315318func initGenerateAwsTfCommandFlags () {
316319 // add flags to sub commands
317320 // TODO Share the help with the interactive generation
321+ generateAwsTfCommand .PersistentFlags ().BoolVar (
322+ & GenerateAwsCommandState .Agentless ,
323+ "agentless" ,
324+ false ,
325+ "enable agentless integration" )
318326 generateAwsTfCommand .PersistentFlags ().BoolVar (
319327 & GenerateAwsCommandState .Cloudtrail ,
320328 "cloudtrail" ,
@@ -486,6 +494,10 @@ func validateAwsProfile(val interface{}) error {
486494 return validateStringWithRegex (val , fmt .Sprintf (`^%s$` , AwsProfileRegex ), "invalid profile name supplied" )
487495}
488496
497+ func promptAgentlessQuestions (config * aws.GenerateAwsTfConfigurationArgs ) error {
498+ return nil
499+ }
500+
489501func promptAwsCtQuestions (config * aws.GenerateAwsTfConfigurationArgs , extraState * AwsGenerateCommandExtraState ) error {
490502 // Only ask these questions if configure cloudtrail is true
491503 if err := SurveyMultipleQuestionWithValidation ([]SurveyQuestionWithValidationArgs {
@@ -770,6 +782,11 @@ func askAdvancedAwsOptions(config *aws.GenerateAwsTfConfigurationArgs, extraStat
770782 // we can have other accounts even if we only have Config integration (Scenario 7)
771783 var options []string
772784
785+ // Only show Advanced Agentless options if Agentless integration is set to true
786+ if config .Agentless {
787+ options = append (options , AdvancedOptAgentless )
788+ }
789+
773790 // Determine if user specified name for Config is potentially required
774791 if config .Config {
775792 options = append (options , QuestionCustomizeConfigName )
@@ -799,6 +816,10 @@ func askAdvancedAwsOptions(config *aws.GenerateAwsTfConfigurationArgs, extraStat
799816
800817 // Based on response, prompt for actions
801818 switch answer {
819+ case AdvancedOptAgentless :
820+ if err := promptAgentlessQuestions (config ); err != nil {
821+ return err
822+ }
802823 case AdvancedOptCloudTrail :
803824 if err := promptAwsCtQuestions (config , extraState ); err != nil {
804825 return err
@@ -843,11 +864,6 @@ func askAdvancedAwsOptions(config *aws.GenerateAwsTfConfigurationArgs, extraStat
843864 return nil
844865}
845866
846- func configOrCloudtrailEnabled (config * aws.GenerateAwsTfConfigurationArgs ) * bool {
847- cloudtrailOrConfigEnabled := config .Cloudtrail || config .Config
848- return & cloudtrailOrConfigEnabled
849- }
850-
851867func awsConfigIsEmpty (g * aws.GenerateAwsTfConfigurationArgs ) bool {
852868 return ! g .Cloudtrail &&
853869 ! g .Config &&
@@ -893,6 +909,10 @@ func promptAwsGenerate(
893909 // These are the core questions that should be asked. Region required for provider block
894910 if err := SurveyMultipleQuestionWithValidation (
895911 []SurveyQuestionWithValidationArgs {
912+ {
913+ Prompt : & survey.Confirm {Message : QuestionEnableAgentless , Default : config .Agentless },
914+ Response : & config .Agentless ,
915+ },
896916 {
897917 Prompt : & survey.Confirm {Message : QuestionAwsEnableConfig , Default : config .Config },
898918 Response : & config .Config ,
@@ -905,20 +925,19 @@ func promptAwsGenerate(
905925 return err
906926 }
907927
928+ // Validate one of agentless, config or cloudtrail was enabled; otherwise error out
929+ if ! config .Agentless && ! config .Config && ! config .Cloudtrail {
930+ return errors .New ("must enable agentless, cloudtrail or config" )
931+ }
932+
908933 if err := SurveyQuestionInteractiveOnly (SurveyQuestionWithValidationArgs {
909934 Prompt : & survey.Input {Message : QuestionAwsRegion , Default : config .AwsRegion },
910935 Response : & config .AwsRegion ,
911936 Opts : []survey.AskOpt {survey .WithValidator (survey .Required ), survey .WithValidator (validateAwsRegion )},
912- Checks : []* bool {configOrCloudtrailEnabled (config )},
913937 }); err != nil {
914938 return err
915939 }
916940
917- // Validate one of config or cloudtrail was enabled; otherwise error out
918- if ! config .Config && ! config .Cloudtrail {
919- return errors .New ("must enable cloudtrail or config" )
920- }
921-
922941 // Find out if the customer wants to specify more advanced features
923942 if err := SurveyQuestionInteractiveOnly (SurveyQuestionWithValidationArgs {
924943 Prompt : & survey.Confirm {Message : QuestionAwsConfigAdvanced , Default : extraState .AskAdvanced },
0 commit comments