Skip to content

Commit bdeb8eb

Browse files
authored
feat(amplify): support performance mode in Branch (#18598)
Add support for [performance mode](https://docs.aws.amazon.com/amplify/latest/userguide/ttl.html#Performance-mode ) in Amplify branches. Performance mode optimizes for faster hosting performance by keeping content cached at the edge for a longer interval. Closes #18557. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 73a889e commit bdeb8eb

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

packages/@aws-cdk/aws-amplify/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ Add branches:
9797
declare const amplifyApp: amplify.App;
9898

9999
const master = amplifyApp.addBranch('master'); // `id` will be used as repo branch name
100-
const dev = amplifyApp.addBranch('dev');
100+
const dev = amplifyApp.addBranch('dev', {
101+
performanceMode: true, // optional, enables performance mode
102+
});
101103
dev.addEnvironment('STAGE', 'dev');
102104
```
103105

packages/@aws-cdk/aws-amplify/lib/branch.ts

+12
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ export interface BranchOptions {
114114
* @default - no asset
115115
*/
116116
readonly asset?: Asset
117+
118+
/**
119+
* Enables performance mode for the branch.
120+
*
121+
* Performance mode optimizes for faster hosting performance by keeping content cached at the edge
122+
* for a longer interval. When performance mode is enabled, hosting configuration or code changes
123+
* can take up to 10 minutes to roll out.
124+
*
125+
* @default false
126+
*/
127+
readonly performanceMode?: boolean;
117128
}
118129

119130
/**
@@ -168,6 +179,7 @@ export class Branch extends Resource implements IBranch {
168179
environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.environmentVariables) }, { omitEmptyArray: true }),
169180
pullRequestEnvironmentName: props.pullRequestEnvironmentName,
170181
stage: props.stage,
182+
enablePerformanceMode: props.performanceMode,
171183
});
172184

173185
this.arn = branch.attrArn;

packages/@aws-cdk/aws-amplify/test/branch.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,15 @@ test('with asset deployment', () => {
162162
},
163163
});
164164
});
165+
166+
test('with performance mode', () => {
167+
// WHEN
168+
app.addBranch('dev', {
169+
performanceMode: true,
170+
});
171+
172+
// THEN
173+
Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', {
174+
EnablePerformanceMode: true,
175+
});
176+
});

0 commit comments

Comments
 (0)