Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(s3objectlambda): open s3 access point arn #32661

Merged
merged 8 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-s3objectlambda-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,16 @@ 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
import * as s3objectlambda from '@aws-cdk/aws-s3objectlambda-alpha';

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.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -98,6 +101,14 @@ test('Can create a valid access point', () => {
],
},
},
S3AccessPointArn: {
Value: {
'Fn::GetAtt': [
'MyObjectLambdaSupportingAccessPointA2D2026E',
'Arn',
],
},
},
VirtualHostedRegionalUrl: {
Value: {
'Fn::Join': [
Expand Down
Loading