From fd5a4f1fe5bd4fb85265b895eec4c36349a8bf64 Mon Sep 17 00:00:00 2001 From: biffgaut Date: Mon, 27 Mar 2023 17:49:15 -0400 Subject: [PATCH] Set loggingBucket in response --- .../@aws-solutions-constructs/core/lib/s3-bucket-helper.ts | 3 +++ .../core/test/s3-bucket-helper.test.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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", {