diff --git a/source/patterns/@aws-solutions-constructs/core/lib/s3-bucket-helper.ts b/source/patterns/@aws-solutions-constructs/core/lib/s3-bucket-helper.ts index d99d72f3c..27ca98fa8 100644 --- a/source/patterns/@aws-solutions-constructs/core/lib/s3-bucket-helper.ts +++ b/source/patterns/@aws-solutions-constructs/core/lib/s3-bucket-helper.ts @@ -148,7 +148,10 @@ export function buildS3Bucket(scope: Construct, } loggingBucket = createLoggingBucket(scope, _loggingBucketId, loggingBucketProps); + } else if (props.bucketProps?.serverAccessLogsBucket) { + loggingBucket = props.bucketProps?.serverAccessLogsBucket as s3.Bucket; } + // Attach the Default Life Cycle policy ONLY IF the versioning is ENABLED if (props.bucketProps?.versioned === undefined || props.bucketProps.versioned) { customBucketProps = DefaultS3Props(loggingBucket, lifecycleRules); diff --git a/source/patterns/@aws-solutions-constructs/core/test/s3-bucket-helper.test.ts b/source/patterns/@aws-solutions-constructs/core/test/s3-bucket-helper.test.ts index 43987768d..81b07b03a 100644 --- a/source/patterns/@aws-solutions-constructs/core/test/s3-bucket-helper.test.ts +++ b/source/patterns/@aws-solutions-constructs/core/test/s3-bucket-helper.test.ts @@ -230,7 +230,7 @@ test('s3 bucket with LoggingBucket and versioning turned off', () => { expect(buildS3BucketResponse.bucket).toBeDefined(); // The line below fails, this appears to be a bug. Entered Issue 906 - // expect(response.loggingBucket).toBeDefined(); + expect(buildS3BucketResponse.loggingBucket).toBeDefined(); const template = Template.fromStack(stack); template.hasResourceProperties("AWS::S3::Bucket", {