diff --git a/pkg/clients/AwsClient.go b/pkg/clients/AwsClient.go index 1870156..35bb5e7 100644 --- a/pkg/clients/AwsClient.go +++ b/pkg/clients/AwsClient.go @@ -535,7 +535,7 @@ func (o *AwsClient) FillNotificationDetails(notification *Notification, function } func calculateStackTemplate(trailName string, cfg *aws.Config, config i.AWSInput) (error, string) { - templateFile := "utils/unified-template.template" + templateFile := "unified-template.template" content, err := os.ReadFile(templateFile) if err != nil { return err, "" @@ -617,10 +617,18 @@ func (o *AwsClient) getConfigForLambda() *aws.Config { func uploadFuncClarityCode(cfg *aws.Config, keyPath string, bucket string) error { s3Client := s3.NewFromConfig(*cfg) - _, err := s3Client.CreateBucket(context.TODO(), &s3.CreateBucketInput{ - Bucket: aws.String(bucket), - CreateBucketConfiguration: &s3types.CreateBucketConfiguration{LocationConstraint: s3types.BucketLocationConstraint(cfg.Region)}, - }) + var err error + if cfg.Region != "us-east-1" { + _, err = s3Client.CreateBucket(context.TODO(), &s3.CreateBucketInput{ + Bucket: aws.String(bucket), + CreateBucketConfiguration: &s3types.CreateBucketConfiguration{LocationConstraint: s3types.BucketLocationConstraint(cfg.Region)}, + }) + } else { + _, err = s3Client.CreateBucket(context.TODO(), &s3.CreateBucketInput{ + Bucket: aws.String(bucket), + }) + } + var bne *s3types.BucketAlreadyOwnedByYou if err != nil && !errors.As(err, &bne) { return err diff --git a/test/e2e_test.sh b/test/e2e_test.sh index 734c082..9fcf585 100755 --- a/test/e2e_test.sh +++ b/test/e2e_test.sh @@ -10,7 +10,7 @@ go build testing_lambda.go echo "testing lambda built successfully" cd ../.. -cp ./run_env/utils/unified-template.template ./test/utils/ +cp ./run_env/utils/unified-template.template ./test/ echo "stack template copied to test folder" echo "e2e tests started"