From 045e03c6523a32ae898691e5585996afd4c1ae89 Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Fri, 27 Dec 2024 00:11:28 +0900 Subject: [PATCH 1/5] feat(aws-s3objectlambda): open s3 access point arn --- .../aws-s3objectlambda-alpha/lib/access-point.ts | 6 ++++++ .../test/s3objectlambda.test.ts | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts b/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts index 7955ba3e47e1a..486e4902472ef 100644 --- a/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts +++ b/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts @@ -201,6 +201,11 @@ export class AccessPoint extends AccessPointBase { */ public readonly accessPointCreationDate: string; + /** + * The ARN of the S3 access point. + */ + public readonly s3AccessPointArn: string; + constructor(scope: Construct, id: string, props: AccessPointProps) { super(scope, id, { physicalName: props.accessPointName, @@ -241,6 +246,7 @@ export class AccessPoint extends AccessPointBase { ], }, }); + this.s3AccessPointArn = supporting.attrArn; this.accessPointName = accessPoint.ref; this.accessPointArn = accessPoint.attrArn; this.accessPointCreationDate = accessPoint.attrCreationDate; diff --git a/packages/@aws-cdk/aws-s3objectlambda-alpha/test/s3objectlambda.test.ts b/packages/@aws-cdk/aws-s3objectlambda-alpha/test/s3objectlambda.test.ts index b3823e2bb0dc2..cbabde70b0ac1 100644 --- a/packages/@aws-cdk/aws-s3objectlambda-alpha/test/s3objectlambda.test.ts +++ b/packages/@aws-cdk/aws-s3objectlambda-alpha/test/s3objectlambda.test.ts @@ -46,6 +46,9 @@ test('Can create a valid access point', () => { regional: false, }), }); + new cdk.CfnOutput(stack, 'S3AccessPointArn', { + value: accessPoint.s3AccessPointArn, + }); expect(Template.fromStack(stack).findOutputs('*')).toEqual( { @@ -98,6 +101,14 @@ test('Can create a valid access point', () => { ], }, }, + S3AccessPointArn: { + Value: { + 'Fn::GetAtt': [ + 'MyObjectLambdaSupportingAccessPointA2D2026E', + 'Arn', + ], + }, + }, VirtualHostedRegionalUrl: { Value: { 'Fn::Join': [ From 9bb014ff1204fd0aba123008a42528e9c1473c8f Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Fri, 27 Dec 2024 00:22:45 +0900 Subject: [PATCH 2/5] chore: add attribute comment --- packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts b/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts index 486e4902472ef..bf18042ce18d8 100644 --- a/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts +++ b/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts @@ -203,6 +203,7 @@ export class AccessPoint extends AccessPointBase { /** * The ARN of the S3 access point. + * @attribute */ public readonly s3AccessPointArn: string; From 0e0a7d14ae575b3555e89b24ff5034efbe96cc1b Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Sun, 5 Jan 2025 00:32:08 +0900 Subject: [PATCH 3/5] fix: remove incorrect attribute --- packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts b/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts index bf18042ce18d8..486e4902472ef 100644 --- a/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts +++ b/packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts @@ -203,7 +203,6 @@ export class AccessPoint extends AccessPointBase { /** * The ARN of the S3 access point. - * @attribute */ public readonly s3AccessPointArn: string; From ce904092584104370931c81465392a653554146d Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Sun, 5 Jan 2025 00:41:05 +0900 Subject: [PATCH 4/5] docs: add usage of s3accesspoint arn --- packages/@aws-cdk/aws-s3objectlambda-alpha/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md b/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md index 127634cde958a..3143c255d1be3 100644 --- a/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md +++ b/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md @@ -92,3 +92,15 @@ new s3objectlambda.AccessPoint(stack, 'MyObjectLambda', { }, }); ``` + +## Accessing the S3 AccessPoint ARN + +If you need access to the s3 accesspoint, you can get its ARN like so: + +```ts +declare const accessPoint: s3objectlambda.AccessPoint; + +const s3AccessPointArn = accessPoint.s3AccessPointArn; +``` + +This is only supported for AccessPoints created in the stack - currently you're unable to get the S3 AccessPoint ARN for imported AccessPoints. To do that you'd have to know the S3 bucket name beforehand. From 65175bb2a4f83405fbe6f3f616e755eb1c8c442f Mon Sep 17 00:00:00 2001 From: tomoki10 Date: Sun, 5 Jan 2025 13:34:21 +0900 Subject: [PATCH 5/5] docs: add required import statement --- packages/@aws-cdk/aws-s3objectlambda-alpha/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md b/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md index 3143c255d1be3..a356fe672c5e8 100644 --- a/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md +++ b/packages/@aws-cdk/aws-s3objectlambda-alpha/README.md @@ -98,8 +98,9 @@ new s3objectlambda.AccessPoint(stack, 'MyObjectLambda', { If you need access to the s3 accesspoint, you can get its ARN like so: ```ts -declare const accessPoint: s3objectlambda.AccessPoint; +import * as s3objectlambda from '@aws-cdk/aws-s3objectlambda-alpha'; +declare const accessPoint: s3objectlambda.AccessPoint; const s3AccessPointArn = accessPoint.s3AccessPointArn; ```