Skip to content

Commit

Permalink
feat(amplify) Add platform property to Amplify AppProps
Browse files Browse the repository at this point in the history
Adds AppPlatforms enum for WEB, WEB_COMPUTE or WEB_DYNAMIC
Adds platform property to AppProps
Passes platform property to declared Amplify app

fixes aws#24076
  • Loading branch information
kevinold committed Feb 8, 2023
1 parent 08a2f36 commit e54c6ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ export interface ISourceCodeProvider {
bind(app: App): SourceCodeProviderConfig;
}

/**
* The platform for the Amplify app.
*/
export enum AppPlatforms {
WEB = 'WEB',
WEB_COMPUTE = 'WEB_COMPUTE',
WEB_DYNAMIC = 'WEB_DYNAMIC',
}

/**
* Properties for an App
*/
Expand Down Expand Up @@ -159,6 +168,16 @@ export interface AppProps {
* @default - a new role is created
*/
readonly role?: iam.IRole;

/**
* The platform for the Amplify app.
* For a static app, set the platform type to WEB.
* For a dynamic server-side rendered (SSR) app, set the platform type to WEB_COMPUTE.
* For an app requiring Amplify Hosting's original SSR support only, set the platform type to WEB_DYNAMIC.
*
* @default WEB
*/
readonly platform?: AppPlatforms;
}

/**
Expand Down Expand Up @@ -249,6 +268,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
oauthToken: sourceCodeProviderOptions?.oauthToken?.unsafeUnwrap(), // Safe usage
repository: sourceCodeProviderOptions?.repository,
customHeaders: props.customResponseHeaders ? renderCustomResponseHeaders(props.customResponseHeaders) : undefined,
platform: props.platform,
});

this.appId = app.attrAppId;
Expand Down
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as codebuild from '@aws-cdk/aws-codebuild';
import * as codecommit from '@aws-cdk/aws-codecommit';
import { SecretValue, Stack } from '@aws-cdk/core';
import * as amplify from '../lib';
import { AppPlatforms } from '../lib';

let stack: Stack;
beforeEach(() => {
Expand Down Expand Up @@ -442,3 +443,20 @@ test('with custom headers', () => {
},
});
});

test('with WEB_COMPUTE platform', () => {
// WHEN
new amplify.App(stack, 'App', {
sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
owner: 'aws',
repository: 'aws-cdk',
oauthToken: SecretValue.unsafePlainText('secret'),
}),
platform: AppPlatforms.WEB_COMPUTE
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Amplify::App', {
Platform: "WEB_COMPUTE",
});
});

0 comments on commit e54c6ee

Please sign in to comment.