Skip to content

Commit 0486b9c

Browse files
authored
feat(s3objectlambda): open s3 access point arn (#32661)
### Issue # (if applicable) Closes #31950 . ### Reason for this change Previously, users needed to manually construct ARN strings when using S3AccessPoint. This update exposes the S3AccessPoint ARN directly to reduce implementation effort. ### Description of changes This change makes the S3AccessPoint accessible as a property for reuse across the codebase. ### Describe any new or updated permissions being added No ### Description of how you validated changes - Added test cases to verify the newly exposed S3AccessPoint property in the existing unit test suite. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 693afea commit 0486b9c

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

packages/@aws-cdk/aws-s3objectlambda-alpha/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,16 @@ new s3objectlambda.AccessPoint(stack, 'MyObjectLambda', {
9292
},
9393
});
9494
```
95+
96+
## Accessing the S3 AccessPoint ARN
97+
98+
If you need access to the s3 accesspoint, you can get its ARN like so:
99+
100+
```ts
101+
import * as s3objectlambda from '@aws-cdk/aws-s3objectlambda-alpha';
102+
103+
declare const accessPoint: s3objectlambda.AccessPoint;
104+
const s3AccessPointArn = accessPoint.s3AccessPointArn;
105+
```
106+
107+
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.

packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ export class AccessPoint extends AccessPointBase {
201201
*/
202202
public readonly accessPointCreationDate: string;
203203

204+
/**
205+
* The ARN of the S3 access point.
206+
*/
207+
public readonly s3AccessPointArn: string;
208+
204209
constructor(scope: Construct, id: string, props: AccessPointProps) {
205210
super(scope, id, {
206211
physicalName: props.accessPointName,
@@ -241,6 +246,7 @@ export class AccessPoint extends AccessPointBase {
241246
],
242247
},
243248
});
249+
this.s3AccessPointArn = supporting.attrArn;
244250
this.accessPointName = accessPoint.ref;
245251
this.accessPointArn = accessPoint.attrArn;
246252
this.accessPointCreationDate = accessPoint.attrCreationDate;

packages/@aws-cdk/aws-s3objectlambda-alpha/test/s3objectlambda.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ test('Can create a valid access point', () => {
4646
regional: false,
4747
}),
4848
});
49+
new cdk.CfnOutput(stack, 'S3AccessPointArn', {
50+
value: accessPoint.s3AccessPointArn,
51+
});
4952

5053
expect(Template.fromStack(stack).findOutputs('*')).toEqual(
5154
{
@@ -98,6 +101,14 @@ test('Can create a valid access point', () => {
98101
],
99102
},
100103
},
104+
S3AccessPointArn: {
105+
Value: {
106+
'Fn::GetAtt': [
107+
'MyObjectLambdaSupportingAccessPointA2D2026E',
108+
'Arn',
109+
],
110+
},
111+
},
101112
VirtualHostedRegionalUrl: {
102113
Value: {
103114
'Fn::Join': [

0 commit comments

Comments
 (0)