diff --git a/packages/@aws-cdk/aws-amplify/README.md b/packages/@aws-cdk/aws-amplify/README.md index 04d9f0d95bf08..fffaf2ac97bcf 100644 --- a/packages/@aws-cdk/aws-amplify/README.md +++ b/packages/@aws-cdk/aws-amplify/README.md @@ -97,7 +97,9 @@ Add branches: declare const amplifyApp: amplify.App; const master = amplifyApp.addBranch('master'); // `id` will be used as repo branch name -const dev = amplifyApp.addBranch('dev'); +const dev = amplifyApp.addBranch('dev', { + performanceMode: true, // optional, enables performance mode +}); dev.addEnvironment('STAGE', 'dev'); ``` diff --git a/packages/@aws-cdk/aws-amplify/lib/branch.ts b/packages/@aws-cdk/aws-amplify/lib/branch.ts index 3298f7a246056..40c1bdb3d0671 100644 --- a/packages/@aws-cdk/aws-amplify/lib/branch.ts +++ b/packages/@aws-cdk/aws-amplify/lib/branch.ts @@ -114,6 +114,17 @@ export interface BranchOptions { * @default - no asset */ readonly asset?: Asset + + /** + * Enables performance mode for the branch. + * + * Performance mode optimizes for faster hosting performance by keeping content cached at the edge + * for a longer interval. When performance mode is enabled, hosting configuration or code changes + * can take up to 10 minutes to roll out. + * + * @default false + */ + readonly performanceMode?: boolean; } /** @@ -168,6 +179,7 @@ export class Branch extends Resource implements IBranch { environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.environmentVariables) }, { omitEmptyArray: true }), pullRequestEnvironmentName: props.pullRequestEnvironmentName, stage: props.stage, + enablePerformanceMode: props.performanceMode, }); this.arn = branch.attrArn; diff --git a/packages/@aws-cdk/aws-amplify/test/branch.test.ts b/packages/@aws-cdk/aws-amplify/test/branch.test.ts index ba8e517205beb..888a92117fb9c 100644 --- a/packages/@aws-cdk/aws-amplify/test/branch.test.ts +++ b/packages/@aws-cdk/aws-amplify/test/branch.test.ts @@ -162,3 +162,15 @@ test('with asset deployment', () => { }, }); }); + +test('with performance mode', () => { + // WHEN + app.addBranch('dev', { + performanceMode: true, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + EnablePerformanceMode: true, + }); +});