Skip to content

Commit a02c656

Browse files
authored
feat(amplify): support build compute type (#34796)
### Issue # (if applicable) N/A ### Reason for this change Amplify supports customizable build instances, but L2 Construct does not support it. https://aws.amazon.com/about-aws/whats-new/2025/05/aws-amplify-hosting-customizable-build-instances/ ### Description of changes Add `buildComputeType` property. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Add unit tests and an integ test. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6cf6dc8 commit a02c656

File tree

13 files changed

+32344
-0
lines changed

13 files changed

+32344
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,18 @@ const amplifyApp = new amplify.App(this, 'MyApp', {
353353
});
354354
```
355355

356+
## Build Compute Type
357+
358+
You can specify the build compute type by setting the `buildComputeType` property.
359+
360+
For more information, see [Configuring the build instance for an Amplify application](https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-instance.html).
361+
362+
```ts
363+
const amplifyApp = new amplify.App(this, 'MyApp', {
364+
buildComputeType: amplify.BuildComputeType.LARGE_16GB,
365+
});
366+
```
367+
356368
## Deploying Assets
357369

358370
`sourceCodeProvider` is optional; when this is not specified the Amplify app can be deployed to using `.zip` packages. The `asset` property can be used to deploy S3 assets to Amplify as part of the CDK:

packages/@aws-cdk/aws-amplify-alpha/lib/app.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ export interface AppProps {
184184
* @default undefined - a new role is created when `platform` is `Platform.WEB_COMPUTE` or `Platform.WEB_DYNAMIC`, otherwise no compute role
185185
*/
186186
readonly computeRole?: iam.IRole;
187+
188+
/**
189+
* Specifies the size of the build instance.
190+
*
191+
* @default undefined - Amplify default setting is `BuildComputeType.STANDARD_8GB`.
192+
*/
193+
readonly buildComputeType?: BuildComputeType;
187194
}
188195

189196
/**
@@ -311,6 +318,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
311318
repository: sourceCodeProviderOptions?.repository,
312319
customHeaders: props.customResponseHeaders ? renderCustomResponseHeaders(props.customResponseHeaders, this) : undefined,
313320
platform: appPlatform,
321+
jobConfig: props.buildComputeType ? { buildComputeType: props.buildComputeType } : undefined,
314322
});
315323

316324
this.appId = app.attrAppId;
@@ -648,3 +656,25 @@ export enum CacheConfigType {
648656
*/
649657
AMPLIFY_MANAGED_NO_COOKIES = 'AMPLIFY_MANAGED_NO_COOKIES',
650658
}
659+
660+
/**
661+
* Specifies the size of the build instance.
662+
*
663+
* @link https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-instance.html
664+
*/
665+
export enum BuildComputeType {
666+
/**
667+
* vCPUs: 4, Memory: 8 GiB, Disk space: 128 GB
668+
*/
669+
STANDARD_8GB = 'STANDARD_8GB',
670+
671+
/**
672+
* vCPUs: 8, Memory: 16 GiB, Disk space: 128 GB
673+
*/
674+
LARGE_16GB = 'LARGE_16GB',
675+
676+
/**
677+
* vCPUs: 36, Memory: 72 GiB, Disk space: 256 GB
678+
*/
679+
XLARGE_72GB = 'XLARGE_72GB',
680+
}

packages/@aws-cdk/aws-amplify-alpha/test/app.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,3 +633,17 @@ test('throws when compute role is set with a non SSR app', () => {
633633
});
634634
}).toThrow('`computeRole` can only be specified for `Platform.WEB_COMPUTE` or `Platform.WEB_DYNAMIC`.');
635635
});
636+
637+
test.each([amplify.BuildComputeType.STANDARD_8GB, amplify.BuildComputeType.LARGE_16GB, amplify.BuildComputeType.XLARGE_72GB])('create an app with buildComputeType is set to %s', (buildComputeType) => {
638+
// WHEN
639+
new amplify.App(stack, 'App', {
640+
buildComputeType,
641+
});
642+
643+
// THEN
644+
Template.fromStack(stack).hasResourceProperties('AWS::Amplify::App', {
645+
JobConfig: {
646+
BuildComputeType: buildComputeType,
647+
},
648+
});
649+
});

0 commit comments

Comments
 (0)