@@ -221,6 +221,7 @@ func TestGenerationAwsAdvancedOptsConsolidatedAndForceDestroy(t *testing.T) {
221221 MsgRsp {cmd .QuestionBucketName , "" },
222222 MsgRsp {cmd .QuestionBucketEnableEncryption , "y" },
223223 MsgRsp {cmd .QuestionBucketSseKeyArn , "" },
224+ MsgRsp {cmd .QuestionS3BucketNotification , "" },
224225 // SNS Topic Questions
225226 MsgRsp {cmd .QuestionsUseExistingSNSTopic , "n" },
226227 MsgRsp {cmd .QuestionSnsTopicName , "" },
@@ -329,6 +330,7 @@ func TestGenerationAwsAdvancedOptsConsolidatedWithSubAccounts(t *testing.T) {
329330 MsgRsp {cmd .QuestionBucketName , "" },
330331 MsgRsp {cmd .QuestionBucketEnableEncryption , "y" },
331332 MsgRsp {cmd .QuestionBucketSseKeyArn , "" },
333+ MsgRsp {cmd .QuestionS3BucketNotification , "" },
332334 // SNS Topic Questions
333335 MsgRsp {cmd .QuestionsUseExistingSNSTopic , "n" },
334336 MsgRsp {cmd .QuestionSnsTopicName , "" },
@@ -594,6 +596,7 @@ func TestGenerationAwsAdvancedOptsCreateNewElements(t *testing.T) {
594596 MsgRsp {cmd .QuestionBucketName , bucketName },
595597 MsgRsp {cmd .QuestionBucketEnableEncryption , "y" },
596598 MsgRsp {cmd .QuestionBucketSseKeyArn , kmsArn },
599+ MsgRsp {cmd .QuestionS3BucketNotification , "" },
597600 // SNS Topic Questions
598601 MsgRsp {cmd .QuestionsUseExistingSNSTopic , "n" },
599602 MsgRsp {cmd .QuestionSnsTopicName , topicName },
@@ -823,6 +826,96 @@ func TestGenerationAwsLaceworkProfile(t *testing.T) {
823826 assert .Equal (t , buildTf , tfResult )
824827}
825828
829+ func TestGenerationAwsS3BucketNotification (t * testing.T ) {
830+ os .Setenv ("LW_NOCACHE" , "true" )
831+ defer os .Setenv ("LW_NOCACHE" , "" )
832+ var final string
833+ var runError error
834+ region := "us-west-2"
835+
836+ tfResult := runGenerateTest (t ,
837+ func (c * expect.Console ) {
838+ expectsCliOutput (t , c , []MsgRspHandler {
839+ MsgRsp {cmd .QuestionAwsEnableConfig , "n" },
840+ MsgRsp {cmd .QuestionEnableCloudtrail , "y" },
841+ MsgRsp {cmd .QuestionAwsRegion , region },
842+ MsgRsp {cmd .QuestionAwsConfigAdvanced , "n" },
843+ MsgRsp {cmd .QuestionRunTfPlan , "n" },
844+ })
845+
846+ final , _ = c .ExpectEOF ()
847+ },
848+ "generate" ,
849+ "cloud-account" ,
850+ "aws" ,
851+ "--use_s3_bucket_notification" ,
852+ )
853+
854+ assert .Nil (t , runError )
855+ assert .Contains (t , final , "Terraform code saved in" )
856+
857+ buildTf , _ := aws .NewTerraform (region , false , true ,
858+ aws .WithS3BucketNotification (true ),
859+ ).Generate ()
860+ assert .Equal (t , buildTf , tfResult )
861+ }
862+
863+ func TestGenerationAwsS3BucketNotificationInteractive (t * testing.T ) {
864+ os .Setenv ("LW_NOCACHE" , "true" )
865+ defer os .Setenv ("LW_NOCACHE" , "" )
866+ var final string
867+ var runError error
868+ region := "us-west-2"
869+
870+ tfResult := runGenerateTest (t ,
871+ func (c * expect.Console ) {
872+ expectsCliOutput (t , c , []MsgRspHandler {
873+ MsgRsp {cmd .QuestionAwsEnableConfig , "n" },
874+ MsgRsp {cmd .QuestionEnableCloudtrail , "y" },
875+ MsgRsp {cmd .QuestionAwsRegion , region },
876+
877+ MsgRsp {cmd .QuestionAwsConfigAdvanced , "y" },
878+ MsgMenu {cmd .AwsAdvancedOptDone , 0 },
879+
880+ MsgRsp {cmd .QuestionConsolidatedCloudtrail , "" },
881+ MsgRsp {cmd .QuestionUseExistingCloudtrail , "" },
882+ MsgRsp {cmd .QuestionCloudtrailName , "" },
883+ // S3 Questions
884+ MsgRsp {cmd .QuestionForceDestroyS3Bucket , "" },
885+ MsgRsp {cmd .QuestionBucketName , "" },
886+ MsgRsp {cmd .QuestionBucketEnableEncryption , "" },
887+ MsgRsp {cmd .QuestionBucketSseKeyArn , "" },
888+ MsgRsp {cmd .QuestionS3BucketNotification , "y" },
889+ // SNS Topic Questions
890+ MsgRsp {cmd .QuestionsUseExistingSNSTopic , "" },
891+ MsgRsp {cmd .QuestionSnsTopicName , "" },
892+ MsgRsp {cmd .QuestionSnsEnableEncryption , "" },
893+ MsgRsp {cmd .QuestionSnsEncryptionKeyArn , "" },
894+ // SQS Questions
895+ MsgRsp {cmd .QuestionSqsQueueName , "" },
896+ MsgRsp {cmd .QuestionSqsEnableEncryption , "" },
897+ MsgRsp {cmd .QuestionSqsEncryptionKeyArn , "" },
898+
899+ MsgRsp {cmd .QuestionAwsAnotherAdvancedOpt , "n" },
900+ MsgRsp {cmd .QuestionRunTfPlan , "n" },
901+ })
902+
903+ final , _ = c .ExpectEOF ()
904+ },
905+ "generate" ,
906+ "cloud-account" ,
907+ "aws" ,
908+ )
909+
910+ assert .Nil (t , runError )
911+ assert .Contains (t , final , "Terraform code saved in" )
912+
913+ buildTf , _ := aws .NewTerraform (region , false , true ,
914+ aws .WithS3BucketNotification (true ),
915+ ).Generate ()
916+ assert .Equal (t , buildTf , tfResult )
917+ }
918+
826919func runGenerateTest (t * testing.T , conditions func (* expect.Console ), args ... string ) string {
827920 os .Setenv ("HOME" , tfPath )
828921
0 commit comments