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(amplify): support performance mode in Branch #18598

Merged
merged 2 commits into from
Feb 2, 2022
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
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-amplify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
```

Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-amplify/lib/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
});