From 3fd6411075446cd364473e6dbe90c2f05cd18390 Mon Sep 17 00:00:00 2001 From: Sumu Date: Thu, 19 Jan 2023 09:48:14 -0500 Subject: [PATCH 1/8] add feature property to Branch with new unit test --- packages/@aws-cdk/aws-amplify/lib/branch.ts | 8 + .../@aws-cdk/aws-amplify/test/branch.test.ts | 242 +++++++++--------- 2 files changed, 136 insertions(+), 114 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify/lib/branch.ts b/packages/@aws-cdk/aws-amplify/lib/branch.ts index 40c1bdb3d0671..c3b0bcd7688d4 100644 --- a/packages/@aws-cdk/aws-amplify/lib/branch.ts +++ b/packages/@aws-cdk/aws-amplify/lib/branch.ts @@ -125,6 +125,13 @@ export interface BranchOptions { * @default false */ readonly performanceMode?: boolean; + + /** + * The Framework for the branch. + * + * @default - no framework + */ + readonly framework?: string; } /** @@ -180,6 +187,7 @@ export class Branch extends Resource implements IBranch { pullRequestEnvironmentName: props.pullRequestEnvironmentName, stage: props.stage, enablePerformanceMode: props.performanceMode, + framework: props.framework, }); this.arn = branch.attrArn; diff --git a/packages/@aws-cdk/aws-amplify/test/branch.test.ts b/packages/@aws-cdk/aws-amplify/test/branch.test.ts index 0e5255b8d0f2b..4a61df4b975fe 100644 --- a/packages/@aws-cdk/aws-amplify/test/branch.test.ts +++ b/packages/@aws-cdk/aws-amplify/test/branch.test.ts @@ -4,141 +4,155 @@ import { Asset } from '@aws-cdk/aws-s3-assets'; import { SecretValue, Stack } from '@aws-cdk/core'; import * as amplify from '../lib'; -let stack: Stack; -let app: amplify.App; -beforeEach(() => { - stack = new Stack(); - app = new amplify.App(stack, 'App', { - sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: 'aws', - repository: 'aws-cdk', - oauthToken: SecretValue.unsafePlainText('secret'), - }), +describe('amplify app', () => { + let stack: Stack; + let app: amplify.App; + beforeEach(() => { + stack = new Stack(); + app = new amplify.App(stack, 'App', { + sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ + owner: 'aws', + repository: 'aws-cdk', + oauthToken: SecretValue.unsafePlainText('secret'), + }), + }); }); -}); -test('create a branch', () => { - // WHEN - app.addBranch('dev'); + test('create a branch', () => { + // WHEN + app.addBranch('dev'); - // THEN - Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { - AppId: { - 'Fn::GetAtt': [ - 'AppF1B96344', - 'AppId', - ], - }, - BranchName: 'dev', - EnableAutoBuild: true, - EnablePullRequestPreview: true, + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + AppId: { + 'Fn::GetAtt': [ + 'AppF1B96344', + 'AppId', + ], + }, + BranchName: 'dev', + EnableAutoBuild: true, + EnablePullRequestPreview: true, + }); }); -}); -test('with basic auth from credentials', () => { - // WHEN - app.addBranch('dev', { - basicAuth: amplify.BasicAuth.fromCredentials('username', SecretValue.unsafePlainText('password')), - }); + test('with basic auth from credentials', () => { + // WHEN + app.addBranch('dev', { + basicAuth: amplify.BasicAuth.fromCredentials('username', SecretValue.unsafePlainText('password')), + }); - // THEN - Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { - BasicAuthConfig: { - EnableBasicAuth: true, - Password: 'password', - Username: 'username', - }, + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + BasicAuthConfig: { + EnableBasicAuth: true, + Password: 'password', + Username: 'username', + }, + }); }); -}); -test('with basic auth from generated password', () => { - // WHEN - app.addBranch('dev', { - basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), - }); + test('with basic auth from generated password', () => { + // WHEN + app.addBranch('dev', { + basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), + }); - // THEN - Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { - BasicAuthConfig: { - EnableBasicAuth: true, - Password: { - 'Fn::Join': [ - '', - [ - '{{resolve:secretsmanager:', - { - Ref: 'AppdevdevBasicAuthB25D2314', - }, - ':SecretString:password::}}', + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + BasicAuthConfig: { + EnableBasicAuth: true, + Password: { + 'Fn::Join': [ + '', + [ + '{{resolve:secretsmanager:', + { + Ref: 'AppdevdevBasicAuthB25D2314', + }, + ':SecretString:password::}}', + ], ], - ], + }, + Username: 'username', }, - Username: 'username', - }, + }); }); -}); -test('with env vars', () => { - // WHEN - const branch = app.addBranch('dev', { - environmentVariables: { - key1: 'value1', - }, + test('with env vars', () => { + // WHEN + const branch = app.addBranch('dev', { + environmentVariables: { + key1: 'value1', + }, + }); + branch.addEnvironment('key2', 'value2'); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + EnvironmentVariables: [ + { + Name: 'key1', + Value: 'value1', + }, + { + Name: 'key2', + Value: 'value2', + }, + ], + }); }); - branch.addEnvironment('key2', 'value2'); - // THEN - Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { - EnvironmentVariables: [ - { - Name: 'key1', - Value: 'value1', + test('with asset deployment', () => { + // WHEN + const asset = new Asset(app, 'SampleAsset', { + path: path.join(__dirname, './test-asset'), + }); + app.addBranch('dev', { asset }); + + // THEN + Template.fromStack(stack).hasResourceProperties('Custom::AmplifyAssetDeployment', { + ServiceToken: { + 'Fn::GetAtt': [ + 'comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2', + 'Outputs.comamazonawscdkcustomresourcesamplifyassetdeploymentprovideramplifyassetdeploymenthandlerproviderframeworkonEventA449D9A9Arn', + ], + }, + AppId: { + 'Fn::GetAtt': [ + 'AppF1B96344', + 'AppId', + ], }, - { - Name: 'key2', - Value: 'value2', + BranchName: 'dev', + S3ObjectKey: '8c89eadc6be22019c81ed6b9c7d9929ae10de55679fd8e0e9fd4c00f8edc1cda.zip', + S3BucketName: { + 'Fn::Sub': 'cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}', }, - ], + }); }); -}); -test('with asset deployment', () => { - // WHEN - const asset = new Asset(app, 'SampleAsset', { - path: path.join(__dirname, './test-asset'), - }); - app.addBranch('dev', { asset }); + test('with performance mode', () => { + // WHEN + app.addBranch('dev', { + performanceMode: true, + }); - // THEN - Template.fromStack(stack).hasResourceProperties('Custom::AmplifyAssetDeployment', { - ServiceToken: { - 'Fn::GetAtt': [ - 'comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2', - 'Outputs.comamazonawscdkcustomresourcesamplifyassetdeploymentprovideramplifyassetdeploymenthandlerproviderframeworkonEventA449D9A9Arn', - ], - }, - AppId: { - 'Fn::GetAtt': [ - 'AppF1B96344', - 'AppId', - ], - }, - BranchName: 'dev', - S3ObjectKey: '8c89eadc6be22019c81ed6b9c7d9929ae10de55679fd8e0e9fd4c00f8edc1cda.zip', - S3BucketName: { - 'Fn::Sub': 'cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}', - }, + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + EnablePerformanceMode: true, + }); }); -}); -test('with performance mode', () => { - // WHEN - app.addBranch('dev', { - performanceMode: true, - }); + test('with framework', () => { + // WHEN + app.addBranch('dev', { + framework: 'testFramework', + }); - // THEN - Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { - EnablePerformanceMode: true, + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::Branch', { + Framework: 'testFramework', + }); }); -}); +}); \ No newline at end of file From 7e2511f8e0ae96d061ae41804db46b557b2028f4 Mon Sep 17 00:00:00 2001 From: Sumu Date: Tue, 24 Jan 2023 15:46:04 -0500 Subject: [PATCH 2/8] added new property to integ app and updated snapshots --- ...k-amplify-app-asset-deployment.assets.json | 2 +- .../cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 41 +++------------- .../tree.json | 40 ++++++++++++--- .../cdk-amplify-codecommit-app.assets.json | 2 +- .../integ.app-codecommit.js.snapshot/cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 14 +++--- .../tree.json | 46 ++++++++++++----- .../cdk-amplify-app.assets.json | 6 +-- .../cdk-amplify-app.template.json | 3 +- .../test/integ.app.js.snapshot/cdk.out | 2 +- .../test/integ.app.js.snapshot/integ.json | 2 +- .../test/integ.app.js.snapshot/manifest.json | 16 +++--- .../test/integ.app.js.snapshot/tree.json | 49 ++++++++++++++----- .../@aws-cdk/aws-amplify/test/integ.app.ts | 4 +- 17 files changed, 142 insertions(+), 93 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json index b217116c076d6..29c341847d46a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "29.0.0", "files": { "673eedce19cf9e5cb7018f3029adb9937d4c7c7b167af1f80c69613cac83b7da": { "source": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out index 8ecc185e9dbee..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"21.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json index 0a2150f8540d6..63b2f96b46ee6 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "29.0.0", "testCases": { "integ.app-asset-deployment": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json index e855dd58d0e04..249c8fe62771a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "21.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "cdk-amplify-app-asset-deployment.assets": { "type": "cdk:asset-manifest", "properties": { @@ -62,36 +56,15 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } - ], - "AppmainF505BAED": [ - { - "type": "aws:cdk:logicalId", - "data": "AppmainF505BAED", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } - ], - "AppmainDeploymentResource442DE93D": [ - { - "type": "aws:cdk:logicalId", - "data": "AppmainDeploymentResource442DE93D", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } - ], - "comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2": [ - { - "type": "aws:cdk:logicalId", - "data": "comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } ] }, "displayName": "cdk-amplify-app-asset-deployment" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json index a08e8bd6421b3..8b1caf1a0c1e7 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.92" - } - }, "cdk-amplify-app-asset-deployment": { "id": "cdk-amplify-app-asset-deployment", "path": "cdk-amplify-app-asset-deployment", @@ -24,6 +16,14 @@ "id": "Role", "path": "cdk-amplify-app-asset-deployment/App/Role", "children": { + "ImportRole": { + "id": "ImportRole", + "path": "cdk-amplify-app-asset-deployment/App/Role/ImportRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "cdk-amplify-app-asset-deployment/App/Role/Resource", @@ -83,12 +83,36 @@ "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-amplify-app-asset-deployment/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-amplify-app-asset-deployment/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, "constructInfo": { "fqn": "@aws-cdk/core.Stack", "version": "0.0.0" } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.209" + } } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json index 93d2518b4e43d..6da374ed22846 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "files": { "6e52872592f7d527f083f6ccb4f9fb078d5e235d5073d6cdaaba6a8904a37e8c": { "source": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out index 588d7b269d34f..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"20.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json index 3d3cb3cec5373..e5725e48180cf 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "testCases": { "integ.app-codecommit": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json index 021bc1764d444..9d5ea517ff9fb 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "20.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "cdk-amplify-codecommit-app.assets": { "type": "cdk:asset-manifest", "properties": { @@ -83,6 +77,12 @@ ] }, "displayName": "cdk-amplify-codecommit-app" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json index 8a94bd6edc4bc..b62829a6ffe5d 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" - } - }, "cdk-amplify-codecommit-app": { "id": "cdk-amplify-codecommit-app", "path": "cdk-amplify-codecommit-app", @@ -48,6 +40,14 @@ "id": "Role", "path": "cdk-amplify-codecommit-app/App/Role", "children": { + "ImportRole": { + "id": "ImportRole", + "path": "cdk-amplify-codecommit-app/App/Role/ImportRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "cdk-amplify-codecommit-app/App/Role/Resource", @@ -189,17 +189,41 @@ "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-amplify-codecommit-app/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-amplify-codecommit-app/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.85" + "version": "10.1.209" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json index 493a60542444b..3e53a6fdafccd 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json @@ -1,7 +1,7 @@ { - "version": "20.0.0", + "version": "29.0.0", "files": { - "61d61670a5f1b42b9d9a564d09ce8d6715f3e29fb801c67dd4d9d7f153457da9": { + "0cf73e196b98fba8c9b54f62b5169024256c223f33b3a78cd8c3167c66d01c3a": { "source": { "path": "cdk-amplify-app.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "61d61670a5f1b42b9d9a564d09ce8d6715f3e29fb801c67dd4d9d7f153457da9.json", + "objectKey": "0cf73e196b98fba8c9b54f62b5169024256c223f33b3a78cd8c3167c66d01c3a.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json index ddcac808c7c09..17ed948cd59f1 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json @@ -99,7 +99,8 @@ "Name": "key", "Value": "value" } - ] + ], + "Framework": "TestFramework" } } }, diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk.out index 588d7b269d34f..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"20.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/integ.json index c91f15a6149aa..a44589751d01e 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "testCases": { "integ.app": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json index 7e942470c44b0..001ec940bc52c 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "20.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "cdk-amplify-app.assets": { "type": "cdk:asset-manifest", "properties": { @@ -23,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/61d61670a5f1b42b9d9a564d09ce8d6715f3e29fb801c67dd4d9d7f153457da9.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0cf73e196b98fba8c9b54f62b5169024256c223f33b3a78cd8c3167c66d01c3a.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -77,6 +71,12 @@ ] }, "displayName": "cdk-amplify-app" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json index 5d2caafdff6bc..997d54d42d344 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" - } - }, "cdk-amplify-app": { "id": "cdk-amplify-app", "path": "cdk-amplify-app", @@ -24,6 +16,14 @@ "id": "Role", "path": "cdk-amplify-app/App/Role", "children": { + "ImportRole": { + "id": "ImportRole", + "path": "cdk-amplify-app/App/Role/ImportRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "cdk-amplify-app/App/Role/Resource", @@ -168,7 +168,8 @@ "name": "key", "value": "value" } - ] + ], + "framework": "TestFramework" } }, "constructInfo": { @@ -187,17 +188,41 @@ "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-amplify-app/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-amplify-app/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.85" + "version": "10.1.209" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.ts b/packages/@aws-cdk/aws-amplify/test/integ.app.ts index 602ee47b8ada2..ca977ed4d6d9b 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.ts +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.ts @@ -32,7 +32,9 @@ class TestStack extends Stack { target: '/target', }); - const mainBranch = amplifyApp.addBranch('main'); + const mainBranch = amplifyApp.addBranch('main', { + framework: 'TestFramework', + }); mainBranch.addEnvironment('key', 'value'); } } From a358d8f2bbe30ed829c2f9266b035c898151bced Mon Sep 17 00:00:00 2001 From: Sumu Date: Tue, 24 Jan 2023 16:29:35 -0500 Subject: [PATCH 3/8] Added example usage to README --- packages/@aws-cdk/aws-amplify/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/@aws-cdk/aws-amplify/README.md b/packages/@aws-cdk/aws-amplify/README.md index 1ff84b938a323..b153c57ad93ab 100644 --- a/packages/@aws-cdk/aws-amplify/README.md +++ b/packages/@aws-cdk/aws-amplify/README.md @@ -231,6 +231,16 @@ const amplifyApp = new amplify.App(this, 'App', { }); ``` +## Add a Framework property to your Branch + +Use the `framework` property on `BranchOptions` to pass in an optional value for the framework: + +```ts +const amplifyApp = new amplify.App(this, 'MyApp', { + framework: 'ExampleFramework', +}); +``` + ## Deploying Assets `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: From f56a87a6c9c714996bb58978721f0a3625b56ecc Mon Sep 17 00:00:00 2001 From: Sumu Date: Wed, 25 Jan 2023 12:35:27 -0500 Subject: [PATCH 4/8] Updated snapshots test passing --- .../test/integ.app-asset-deployment.js.snapshot/tree.json | 2 +- .../test/integ.app-codecommit.js.snapshot/tree.json | 4 ++-- .../@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json index 8b1caf1a0c1e7..8c45802286fcd 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json @@ -80,7 +80,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-amplify.App", + "fqn": "@aws-cdk/core.Resource", "version": "0.0.0" } }, diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json index b62829a6ffe5d..eecbad2842614 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json @@ -180,13 +180,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-amplify.Branch", + "fqn": "@aws-cdk/core.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-amplify.App", + "fqn": "@aws-cdk/core.Resource", "version": "0.0.0" } }, diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json index 997d54d42d344..613b3ab0f5c55 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json @@ -179,13 +179,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-amplify.Branch", + "fqn": "@aws-cdk/core.Resource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-amplify.App", + "fqn": "@aws-cdk/core.Resource", "version": "0.0.0" } }, From 7d12a5cd60fb7a132a2631b2b88d02913a08e6c2 Mon Sep 17 00:00:00 2001 From: Sumu Date: Wed, 25 Jan 2023 13:04:26 -0500 Subject: [PATCH 5/8] Fix README example for codebuild --- packages/@aws-cdk/aws-amplify/README.md | 3 +- ...k-amplify-app-asset-deployment.assets.json | 2 +- .../cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 41 ++++++++++++--- .../tree.json | 42 ++++------------ .../cdk-amplify-codecommit-app.assets.json | 2 +- .../integ.app-codecommit.js.snapshot/cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 14 +++--- .../tree.json | 50 +++++-------------- 11 files changed, 71 insertions(+), 91 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify/README.md b/packages/@aws-cdk/aws-amplify/README.md index b153c57ad93ab..8b9c9a55dab9c 100644 --- a/packages/@aws-cdk/aws-amplify/README.md +++ b/packages/@aws-cdk/aws-amplify/README.md @@ -236,7 +236,8 @@ const amplifyApp = new amplify.App(this, 'App', { Use the `framework` property on `BranchOptions` to pass in an optional value for the framework: ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +declare const amplifyApp: amplify.App; +amplifyApp.addBranch('feature/next', { framework: 'ExampleFramework', }); ``` diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json index 29c341847d46a..b217116c076d6 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json @@ -1,5 +1,5 @@ { - "version": "29.0.0", + "version": "21.0.0", "files": { "673eedce19cf9e5cb7018f3029adb9937d4c7c7b167af1f80c69613cac83b7da": { "source": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out index d8b441d447f8a..8ecc185e9dbee 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"29.0.0"} \ No newline at end of file +{"version":"21.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json index 63b2f96b46ee6..0a2150f8540d6 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "29.0.0", + "version": "21.0.0", "testCases": { "integ.app-asset-deployment": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json index 249c8fe62771a..e855dd58d0e04 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json @@ -1,6 +1,12 @@ { - "version": "29.0.0", + "version": "21.0.0", "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + }, "cdk-amplify-app-asset-deployment.assets": { "type": "cdk:asset-manifest", "properties": { @@ -56,15 +62,36 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } + ], + "AppmainF505BAED": [ + { + "type": "aws:cdk:logicalId", + "data": "AppmainF505BAED", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "AppmainDeploymentResource442DE93D": [ + { + "type": "aws:cdk:logicalId", + "data": "AppmainDeploymentResource442DE93D", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2": [ + { + "type": "aws:cdk:logicalId", + "data": "comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } ] }, "displayName": "cdk-amplify-app-asset-deployment" - }, - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json index 8c45802286fcd..a08e8bd6421b3 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json @@ -4,6 +4,14 @@ "id": "App", "path": "", "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.92" + } + }, "cdk-amplify-app-asset-deployment": { "id": "cdk-amplify-app-asset-deployment", "path": "cdk-amplify-app-asset-deployment", @@ -16,14 +24,6 @@ "id": "Role", "path": "cdk-amplify-app-asset-deployment/App/Role", "children": { - "ImportRole": { - "id": "ImportRole", - "path": "cdk-amplify-app-asset-deployment/App/Role/ImportRole", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", - "version": "0.0.0" - } - }, "Resource": { "id": "Resource", "path": "cdk-amplify-app-asset-deployment/App/Role/Resource", @@ -80,23 +80,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/core.Resource", - "version": "0.0.0" - } - }, - "BootstrapVersion": { - "id": "BootstrapVersion", - "path": "cdk-amplify-app-asset-deployment/BootstrapVersion", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", - "version": "0.0.0" - } - }, - "CheckBootstrapVersion": { - "id": "CheckBootstrapVersion", - "path": "cdk-amplify-app-asset-deployment/CheckBootstrapVersion", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } } @@ -105,14 +89,6 @@ "fqn": "@aws-cdk/core.Stack", "version": "0.0.0" } - }, - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.209" - } } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json index 6da374ed22846..93d2518b4e43d 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json @@ -1,5 +1,5 @@ { - "version": "29.0.0", + "version": "20.0.0", "files": { "6e52872592f7d527f083f6ccb4f9fb078d5e235d5073d6cdaaba6a8904a37e8c": { "source": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out index d8b441d447f8a..588d7b269d34f 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"29.0.0"} \ No newline at end of file +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json index e5725e48180cf..3d3cb3cec5373 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "29.0.0", + "version": "20.0.0", "testCases": { "integ.app-codecommit": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json index 9d5ea517ff9fb..021bc1764d444 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json @@ -1,6 +1,12 @@ { - "version": "29.0.0", + "version": "20.0.0", "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + }, "cdk-amplify-codecommit-app.assets": { "type": "cdk:asset-manifest", "properties": { @@ -77,12 +83,6 @@ ] }, "displayName": "cdk-amplify-codecommit-app" - }, - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json index eecbad2842614..8a94bd6edc4bc 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json @@ -4,6 +4,14 @@ "id": "App", "path": "", "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.85" + } + }, "cdk-amplify-codecommit-app": { "id": "cdk-amplify-codecommit-app", "path": "cdk-amplify-codecommit-app", @@ -40,14 +48,6 @@ "id": "Role", "path": "cdk-amplify-codecommit-app/App/Role", "children": { - "ImportRole": { - "id": "ImportRole", - "path": "cdk-amplify-codecommit-app/App/Role/ImportRole", - "constructInfo": { - "fqn": "@aws-cdk/core.Resource", - "version": "0.0.0" - } - }, "Resource": { "id": "Resource", "path": "cdk-amplify-codecommit-app/App/Role/Resource", @@ -180,50 +180,26 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "@aws-cdk/aws-amplify.Branch", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Resource", - "version": "0.0.0" - } - }, - "BootstrapVersion": { - "id": "BootstrapVersion", - "path": "cdk-amplify-codecommit-app/BootstrapVersion", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", - "version": "0.0.0" - } - }, - "CheckBootstrapVersion": { - "id": "CheckBootstrapVersion", - "path": "cdk-amplify-codecommit-app/CheckBootstrapVersion", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } } }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - }, - "Tree": { - "id": "Tree", - "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.209" + "version": "10.1.85" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.1.85" } } } \ No newline at end of file From fdfd551d82b612ff45c08770d9819d56a04545dd Mon Sep 17 00:00:00 2001 From: Sumu Date: Wed, 1 Feb 2023 13:10:02 -0500 Subject: [PATCH 6/8] Add platform variable to app construct with unit test --- packages/@aws-cdk/aws-amplify/lib/app.ts | 29 +++++++++++++++++++ .../@aws-cdk/aws-amplify/test/app.test.ts | 16 ++++++++++ 2 files changed, 45 insertions(+) diff --git a/packages/@aws-cdk/aws-amplify/lib/app.ts b/packages/@aws-cdk/aws-amplify/lib/app.ts index 387e89110568b..6870d48265ccf 100644 --- a/packages/@aws-cdk/aws-amplify/lib/app.ts +++ b/packages/@aws-cdk/aws-amplify/lib/app.ts @@ -159,6 +159,34 @@ export interface AppProps { * @default - a new role is created */ readonly role?: iam.IRole; + + /** + * The Platform type of the Amplify application + * + * @default - no platform + */ + readonly platform?: Platform +} + +/** + * The platform type for an Amplify App. + */ +export enum Platform { + /** + * Static app (WEB) + */ + WEB = 'WEB', + + /** + * Dynamic SSR app (WEB_COMPUTE) + */ + WEB_COMPUTE = 'WEB_COMPUTE', + + /** + * App requiring Amplify hosting's original SSR support only + * (WEB_DYNAMIC) + */ + WEB_DYNAMIC = 'WEB_DYNAMIC', } /** @@ -249,6 +277,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; diff --git a/packages/@aws-cdk/aws-amplify/test/app.test.ts b/packages/@aws-cdk/aws-amplify/test/app.test.ts index d778ce133b337..f9297ac50a053 100644 --- a/packages/@aws-cdk/aws-amplify/test/app.test.ts +++ b/packages/@aws-cdk/aws-amplify/test/app.test.ts @@ -442,3 +442,19 @@ test('with custom headers', () => { }, }); }); + +test('create an amplify app with platform ', () => { + // WHEN + new amplify.App(stack, 'App', { + sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ + owner: 'aws', + repository: 'aws-cdk', + oauthToken: SecretValue.unsafePlainText('secret'), + }), + platform: amplify.Platform.WEB, + }); + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Amplify::App', { + Platform: 'WEB', + }); +}); From d36ced6a08d0bd9cbc88f8f25d8745dd6359f503 Mon Sep 17 00:00:00 2001 From: Sumu Date: Wed, 1 Feb 2023 17:01:35 -0500 Subject: [PATCH 7/8] Add platform to integ test and update snapshots --- ...k-amplify-app-asset-deployment.assets.json | 2 +- .../cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 41 +++-------------- .../tree.json | 40 ++++++++++++---- .../cdk-amplify-codecommit-app.assets.json | 2 +- .../integ.app-codecommit.js.snapshot/cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 14 +++--- .../tree.json | 46 ++++++++++++++----- .../cdk-amplify-app.assets.json | 4 +- .../cdk-amplify-app.template.json | 3 +- .../test/integ.app.js.snapshot/manifest.json | 2 +- .../test/integ.app.js.snapshot/tree.json | 9 ++-- .../@aws-cdk/aws-amplify/test/integ.app.ts | 1 + 15 files changed, 98 insertions(+), 74 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json index b217116c076d6..29c341847d46a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "29.0.0", "files": { "673eedce19cf9e5cb7018f3029adb9937d4c7c7b167af1f80c69613cac83b7da": { "source": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out index 8ecc185e9dbee..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"21.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json index 0a2150f8540d6..63b2f96b46ee6 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "29.0.0", "testCases": { "integ.app-asset-deployment": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json index e855dd58d0e04..249c8fe62771a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "21.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "cdk-amplify-app-asset-deployment.assets": { "type": "cdk:asset-manifest", "properties": { @@ -62,36 +56,15 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } - ], - "AppmainF505BAED": [ - { - "type": "aws:cdk:logicalId", - "data": "AppmainF505BAED", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } - ], - "AppmainDeploymentResource442DE93D": [ - { - "type": "aws:cdk:logicalId", - "data": "AppmainDeploymentResource442DE93D", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } - ], - "comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2": [ - { - "type": "aws:cdk:logicalId", - "data": "comamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackcomamazonawscdkcustomresourcesamplifyassetdeploymentproviderNestedStackResource89BDFEB2", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] - } ] }, "displayName": "cdk-amplify-app-asset-deployment" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json index a08e8bd6421b3..7403319e2cbd8 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-asset-deployment.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.92" - } - }, "cdk-amplify-app-asset-deployment": { "id": "cdk-amplify-app-asset-deployment", "path": "cdk-amplify-app-asset-deployment", @@ -24,6 +16,14 @@ "id": "Role", "path": "cdk-amplify-app-asset-deployment/App/Role", "children": { + "ImportRole": { + "id": "ImportRole", + "path": "cdk-amplify-app-asset-deployment/App/Role/ImportRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "cdk-amplify-app-asset-deployment/App/Role/Resource", @@ -83,12 +83,36 @@ "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-amplify-app-asset-deployment/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-amplify-app-asset-deployment/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, "constructInfo": { "fqn": "@aws-cdk/core.Stack", "version": "0.0.0" } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.237" + } } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json index 93d2518b4e43d..6da374ed22846 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk-amplify-codecommit-app.assets.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "files": { "6e52872592f7d527f083f6ccb4f9fb078d5e235d5073d6cdaaba6a8904a37e8c": { "source": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out index 588d7b269d34f..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"20.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json index 3d3cb3cec5373..e5725e48180cf 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "testCases": { "integ.app-codecommit": { "stacks": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json index 021bc1764d444..9d5ea517ff9fb 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "20.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "cdk-amplify-codecommit-app.assets": { "type": "cdk:asset-manifest", "properties": { @@ -83,6 +77,12 @@ ] }, "displayName": "cdk-amplify-codecommit-app" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json index 8a94bd6edc4bc..534c883fa0a3b 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" - } - }, "cdk-amplify-codecommit-app": { "id": "cdk-amplify-codecommit-app", "path": "cdk-amplify-codecommit-app", @@ -48,6 +40,14 @@ "id": "Role", "path": "cdk-amplify-codecommit-app/App/Role", "children": { + "ImportRole": { + "id": "ImportRole", + "path": "cdk-amplify-codecommit-app/App/Role/ImportRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "cdk-amplify-codecommit-app/App/Role/Resource", @@ -189,17 +189,41 @@ "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-amplify-codecommit-app/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-amplify-codecommit-app/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.85" + "version": "10.1.237" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json index 3e53a6fdafccd..dd2c4c53c9fbd 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.assets.json @@ -1,7 +1,7 @@ { "version": "29.0.0", "files": { - "0cf73e196b98fba8c9b54f62b5169024256c223f33b3a78cd8c3167c66d01c3a": { + "78b3f485aa1c0d3637eafd63c728e389ac4a4443ece30b9b46c9d43e2bdb8a4d": { "source": { "path": "cdk-amplify-app.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "0cf73e196b98fba8c9b54f62b5169024256c223f33b3a78cd8c3167c66d01c3a.json", + "objectKey": "78b3f485aa1c0d3637eafd63c728e389ac4a4443ece30b9b46c9d43e2bdb8a4d.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json index 17ed948cd59f1..3076cdef10039 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/cdk-amplify-app.template.json @@ -79,7 +79,8 @@ "AppRole1AF9B530", "Arn" ] - } + }, + "Platform": "WEB" } }, "AppmainF505BAED": { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json index 001ec940bc52c..80ab9fa7fe9a1 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/manifest.json @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0cf73e196b98fba8c9b54f62b5169024256c223f33b3a78cd8c3167c66d01c3a.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/78b3f485aa1c0d3637eafd63c728e389ac4a4443ece30b9b46c9d43e2bdb8a4d.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json index 613b3ab0f5c55..93bd061d7de78 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.js.snapshot/tree.json @@ -136,7 +136,8 @@ "AppRole1AF9B530", "Arn" ] - } + }, + "platform": "WEB" } }, "constructInfo": { @@ -179,13 +180,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "@aws-cdk/aws-amplify.Branch", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "@aws-cdk/aws-amplify.App", "version": "0.0.0" } }, @@ -216,7 +217,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.209" + "version": "10.1.237" } } }, diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.ts b/packages/@aws-cdk/aws-amplify/test/integ.app.ts index ca977ed4d6d9b..7a94868e5d580 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.ts +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.ts @@ -25,6 +25,7 @@ class TestStack extends Stack { }, }, ], + platform: amplify.Platform.WEB, }); amplifyApp.addCustomRule({ From d196c853f24107b074044547a9732b8e0ea538a9 Mon Sep 17 00:00:00 2001 From: Sumu Date: Fri, 3 Feb 2023 14:46:11 -0500 Subject: [PATCH 8/8] Add Platform property to README --- packages/@aws-cdk/aws-amplify/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify/README.md b/packages/@aws-cdk/aws-amplify/README.md index 8b9c9a55dab9c..516dfc7672c3f 100644 --- a/packages/@aws-cdk/aws-amplify/README.md +++ b/packages/@aws-cdk/aws-amplify/README.md @@ -231,12 +231,14 @@ const amplifyApp = new amplify.App(this, 'App', { }); ``` -## Add a Framework property to your Branch +## Adding Platform and Framework properties to your Amplify App Use the `framework` property on `BranchOptions` to pass in an optional value for the framework: ```ts -declare const amplifyApp: amplify.App; +const amplifyApp = new amplify.App(this, 'App', { + platform: amplify.Platform.WEB, +}); amplifyApp.addBranch('feature/next', { framework: 'ExampleFramework', });