Skip to content

Commit 13dcbf1

Browse files
committed
📝 docs: README to reflect new features and breaking changes
1 parent e5e3caa commit 13dcbf1

File tree

2 files changed

+69
-24
lines changed

2 files changed

+69
-24
lines changed

packages/construct/README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ The Turborepo Remote Cache API allows teams to share and reuse build artifacts a
1818
## Features
1919

2020
- :zap: High-performance S3 integration for artifact storage
21-
- :lock: Secure authentication using bearer token
22-
- :chart_with_upwards_trend: Scalable architecture using serverless AWS services
21+
- :lock: Flexible authentication with custom authorizer support
22+
- :key: Pre-signed URL support for direct S3 access
2323
- :globe_with_meridians: Optional custom domain support
2424
- :gear: Easy integration with existing CDK stacks
2525
- :moneybag: Cost-effective usage-based pricing model
@@ -51,6 +51,7 @@ import * as cdk from 'aws-cdk-lib';
5151
import { Construct } from 'constructs';
5252
import { TurboRemoteCache } from 'turbo-remote-cache-construct';
5353
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
54+
import * as lambda from 'aws-cdk-lib/aws-lambda';
5455
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
5556

5657
export class TurboRemoteCacheStack extends cdk.Stack {
@@ -91,7 +92,28 @@ export class TurboRemoteCacheStack extends cdk.Stack {
9192
}
9293
```
9394

94-
The S3 bucket, DynamoDB table, and API Gateway can be configured using the optional props. The defaults are are provided in the jsdoc comments and can be viewed in the [source code](/packages/construct/src/index.ts). The example above uses apiProps to configure a custom domain name for the API Gateway. It also uses artifactsBucketProps to customize the bucketName and removalPolicy to retain the bucket when the stack is deleted. Similar options are available for the DynamoDB table.
95+
The S3 bucket, DynamoDB table, and API Gateway can be configured using the optional props. The defaults are are provided in the jsdoc
96+
comments and can be viewed in the [source code](/packages/construct/src/index.ts). The example above uses apiProps to configure a custom
97+
domain name for the API Gateway. It also uses artifactsBucketProps to customize the bucketName and removalPolicy to retain the bucket when
98+
the stack is deleted. Similar options are available for the DynamoDB table.
99+
100+
## Breaking Changes in 2.0
101+
102+
### Authentication
103+
- Deprecated simple token-based authentication (`turboToken`)
104+
- Added support for custom authorizers via `authorizerFunction`
105+
- Authorizer must provide `teamId` in the context
106+
107+
### Team Identification
108+
- Removed support for `teamSlug` in favor of `teamId`
109+
- All artifact paths now use `teamId` instead of `slug`
110+
- API endpoints expect `teamId` query parameter
111+
112+
### New Features
113+
- Added preflight/presigned URL support for S3 operations
114+
- Added CORS support for S3 bucket
115+
- Added custom user info endpoint support
116+
- Support for direct S3 access using presigned URLs
95117

96118
## Architecture
97119

@@ -101,7 +123,7 @@ The construct uses API Gateway, Lambda, S3 integration, and DynamoDB to create a
101123

102124
- **API Gateway**: Used to create a REST API that will be used to interact with the Remote Cache.
103125
- **Lambda**: Used to handle the API requests and responses for non-artifact related endpoints.
104-
- **S3 Integration**: Allows API Gateway to integrate with S3 without a Lambda function which allows for a larger payload size and lower latency.
126+
- **S3 Integration**: Allows API Gateway to integrate with S3 without a Lambda function which allows for a larger payload size and lower latency. Supports presigned URLs for direct S3 access using preflight requests.
105127
- **S3**: Used to store the Remote Cache artifacts.
106128
- **DynamoDB**: Used to store the Remote Cache events.
107129

packages/construct/src/index.ts

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,37 @@ import * as apigateway from 'aws-cdk-lib/aws-apigateway';
1010
export interface TurboRemoteCacheProps {
1111
/**
1212
* Turbo Token
13-
* used to authenticate requests to the API
13+
* @deprecated Use authorizerFunction instead for authentication
14+
* Used only if custom authorizer is not provided
1415
* @example generate a random string using `openssl rand -base64 32`
15-
* required if custom authorizer (apiProps.defaultMethodOptions.authorizer) is not provided
1616
*/
1717
turboToken?: string;
18+
19+
/**
20+
* Custom authorizer lambda function for API authentication
21+
* This function should return the teamId in the authorizer context
22+
* Replaces the deprecated turboToken authentication
23+
* @example
24+
* ```typescript
25+
* new TurboRemoteCache(this, 'Cache', {
26+
* authorizerFunction: myCustomAuthorizer,
27+
* });
28+
* ```
29+
*/
30+
authorizerFunction?: lambda.Function;
31+
32+
/**
33+
* Custom user info lambda function
34+
* Implements the /v2/user endpoint for retrieving authenticated user information
35+
* @example
36+
* ```typescript
37+
* new TurboRemoteCache(this, 'Cache', {
38+
* userInfoFunction: myUserInfoFunction,
39+
* });
40+
* ```
41+
*/
42+
userInfoFunction?: lambda.Function;
43+
1844
/**
1945
* API Gateway props
2046
* @default
@@ -31,19 +57,23 @@ export interface TurboRemoteCacheProps {
3157
* },
3258
* binaryMediaTypes: ['application/octet-stream'],
3359
*/
34-
apiProps?: Partial<apigateway.RestApiProps>,
60+
apiProps?: Partial<apigateway.RestApiProps>;
61+
3562
/**
3663
* S3 bucket props for the artifacts bucket
3764
* @default
3865
* bucketName: 'turbo-remote-cache-artifacts',
39-
* lifecycleRules: [
40-
* {
41-
* expiration: cdk.Duration.days(30),
42-
* },
43-
* ],
66+
* lifecycleRules: [{ expiration: cdk.Duration.days(30) }],
67+
* cors: [{
68+
* allowedHeaders: ['*'],
69+
* allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.PUT, s3.HttpMethods.HEAD],
70+
* allowedOrigins: ['*'],
71+
* exposedHeaders: ['User-Agent', 'Content-Type', 'Content-Length', 'x-artifact-duration', 'x-artifact-tag'],
72+
* }],
4473
* removalPolicy: cdk.RemovalPolicy.DESTROY,
4574
*/
46-
artifactsBucketProps?: Partial<s3.BucketProps>,
75+
artifactsBucketProps?: Partial<s3.BucketProps>;
76+
4777
/**
4878
* DynamoDB table props for the events table
4979
* @default
@@ -54,19 +84,12 @@ export interface TurboRemoteCacheProps {
5484
* timeToLiveAttribute: 'ttl',
5585
* removalPolicy: cdk.RemovalPolicy.DESTROY,
5686
*/
57-
eventsTableProps?: Partial<dynamodb.TableProps>
58-
/**
59-
* common lambda function props for all lambda functions
60-
*/
61-
lambdaProps?: Partial<lambda.FunctionProps>
62-
/**
63-
* custom authorizer lambda function
64-
*/
65-
authorizerFunction?: lambda.Function
87+
eventsTableProps?: Partial<dynamodb.TableProps>;
88+
6689
/**
67-
* custom user info lambda function
90+
* Common lambda function props for all lambda functions
6891
*/
69-
userInfoFunction?: lambda.Function
92+
lambdaProps?: Partial<lambda.FunctionProps>;
7093
}
7194

7295
export class TurboRemoteCache extends Construct {

0 commit comments

Comments
 (0)