From b6aba2de8d1dfee51fed1d1e0330a622a5fd5e98 Mon Sep 17 00:00:00 2001
From: Lei Jin <166442440+leijin-lw@users.noreply.github.com>
Date: Wed, 18 Sep 2024 12:21:42 -0700
Subject: [PATCH] chore: Allow user to define new cloudtrail name

Signed-off-by: Lei Jin <lei.jin@lacework.net>
---
 lwgenerate/aws/aws.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lwgenerate/aws/aws.go b/lwgenerate/aws/aws.go
index e188a7ed6..d7fa9ae20 100644
--- a/lwgenerate/aws/aws.go
+++ b/lwgenerate/aws/aws.go
@@ -1050,9 +1050,11 @@ func createCloudtrail(args *GenerateAwsTfConfigurationArgs) (*hclwrite.Block, er
 			attributes["consolidated_trail"] = true
 		}
 		// S3 Bucket attributes
+		if args.CloudtrailName != "" {
+			attributes["cloudtrail_name"] = args.CloudtrailName
+		}
 		if args.CloudtrailUseExistingTrail {
 			attributes["use_existing_cloudtrail"] = true
-			attributes["cloudtrail_name"] = args.CloudtrailName
 			attributes["bucket_arn"] = args.ExistingCloudtrailBucketArn
 		} else {
 			if args.BucketName != "" {