Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-amplify-alpha/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ export interface AppProps {
* @default CacheConfigType.AMPLIFY_MANAGED
*/
readonly cacheConfigType?: CacheConfigType;

/**
* The IAM role for an SSR app.
* The Compute role allows the Amplify Hosting compute service to securely access specific AWS resources based on the role's permissions.
* @see https://docs.aws.amazon.com/amplify/latest/userguide/amplify-SSR-compute-role.html
* @default undefined - no compute role
*/
readonly computeRole?: iam.IRole;
}

/**
Expand Down Expand Up @@ -260,6 +268,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
: { enableBasicAuth: false },
buildSpec: props.buildSpec && props.buildSpec.toBuildSpec(),
cacheConfig: props.cacheConfigType ? { type: props.cacheConfigType } : undefined,
computeRoleArn: props.computeRole?.roleArn,
customRules: Lazy.any({ produce: () => this.customRules }, { omitEmptyArray: true }),
description: props.description,
environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.environmentVariables) }, { omitEmptyArray: true }),
Expand Down
20 changes: 20 additions & 0 deletions packages/@aws-cdk/aws-amplify-alpha/test/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Template } from 'aws-cdk-lib/assertions';
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
import * as codecommit from 'aws-cdk-lib/aws-codecommit';
import * as iam from 'aws-cdk-lib/aws-iam';
import { SecretValue, Stack } from 'aws-cdk-lib';
import * as amplify from '../lib';

Expand Down Expand Up @@ -478,3 +479,22 @@ test.each([amplify.CacheConfigType.AMPLIFY_MANAGED, amplify.CacheConfigType.AMPL
},
});
});

test('create a app with compute role', () => {
// WHEN
const computeRole = new iam.Role(stack, 'ComputeRole', {
assumedBy: new iam.ServicePrincipal('amplify.amazonaws.com'),
});

new amplify.App(stack, 'App', {
platform: amplify.Platform.WEB_COMPUTE,
computeRole,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Amplify::App', {
Platform: amplify.Platform.WEB_COMPUTE,
ComputeRoleArn: stack.resolve(computeRole.roleArn),
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"Resources": {
"ComputeRole65BDBE3E": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "amplify.amazonaws.com"
}
}
],
"Version": "2012-10-17"
}
}
},
"AppRole1AF9B530": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "amplify.amazonaws.com"
}
}
],
"Version": "2012-10-17"
}
}
},
"AppF1B96344": {
"Type": "AWS::Amplify::App",
"Properties": {
"BasicAuthConfig": {
"EnableBasicAuth": false
},
"CacheConfig": {
"Type": "AMPLIFY_MANAGED_NO_COOKIES"
},
"ComputeRoleArn": {
"Fn::GetAtt": [
"ComputeRole65BDBE3E",
"Arn"
]
},
"IAMServiceRole": {
"Fn::GetAtt": [
"AppRole1AF9B530",
"Arn"
]
},
"Name": "App",
"Platform": "WEB"
}
},
"AppmainF505BAED": {
"Type": "AWS::Amplify::Branch",
"Properties": {
"AppId": {
"Fn::GetAtt": [
"AppF1B96344",
"AppId"
]
},
"BranchName": "main",
"EnableAutoBuild": true,
"EnablePullRequestPreview": true
}
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading