From 954a506a8e12a3a1358ab57e4fee2a5df8ec52c4 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 14 Nov 2023 14:53:11 -0800 Subject: [PATCH 01/26] build working --- packages/backend-function/package.json | 1 - packages/backend-function/src/factory.test.ts | 37 +--- packages/backend-function/src/factory.ts | 160 +++++++----------- packages/backend-function/tsconfig.json | 1 - packages/backend/src/index.ts | 2 +- packages/function-construct/.npmignore | 14 -- packages/function-construct/API.md | 28 --- packages/function-construct/CHANGELOG.md | 79 --------- .../function-construct/api-extractor.json | 3 - packages/function-construct/package.json | 27 --- .../function-construct/src/construct.test.ts | 74 -------- packages/function-construct/src/construct.ts | 45 ----- packages/function-construct/src/index.ts | 1 - .../test-assets/test-lambda/mock.txt | 2 - packages/function-construct/tsconfig.json | 5 - packages/function-construct/typedoc.json | 3 - 16 files changed, 62 insertions(+), 420 deletions(-) delete mode 100644 packages/function-construct/.npmignore delete mode 100644 packages/function-construct/API.md delete mode 100644 packages/function-construct/CHANGELOG.md delete mode 100644 packages/function-construct/api-extractor.json delete mode 100644 packages/function-construct/package.json delete mode 100644 packages/function-construct/src/construct.test.ts delete mode 100644 packages/function-construct/src/construct.ts delete mode 100644 packages/function-construct/src/index.ts delete mode 100644 packages/function-construct/test-assets/test-lambda/mock.txt delete mode 100644 packages/function-construct/tsconfig.json delete mode 100644 packages/function-construct/typedoc.json diff --git a/packages/backend-function/package.json b/packages/backend-function/package.json index 8735d3e061..903d8d1710 100644 --- a/packages/backend-function/package.json +++ b/packages/backend-function/package.json @@ -19,7 +19,6 @@ "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-storage": "0.2.1", - "@aws-amplify/function-construct-alpha": "^0.2.0", "@aws-amplify/plugin-types": "^0.4.0", "execa": "^7.1.1" }, diff --git a/packages/backend-function/src/factory.test.ts b/packages/backend-function/src/factory.test.ts index 3643097ec3..c0a4c9fcce 100644 --- a/packages/backend-function/src/factory.test.ts +++ b/packages/backend-function/src/factory.test.ts @@ -1,10 +1,8 @@ -import { beforeEach, describe, it, mock } from 'node:test'; -import { Func } from './factory.js'; +import { beforeEach, describe, it } from 'node:test'; +import { defineFunction } from './factory.js'; import { App, Stack } from 'aws-cdk-lib'; import { ConstructFactoryGetInstanceProps } from '@aws-amplify/plugin-types'; import assert from 'node:assert'; -import { fileURLToPath } from 'url'; -import * as path from 'path'; import { StackMetadataBackendOutputStorageStrategy } from '@aws-amplify/backend-output-storage'; import { ConstructContainerStub, @@ -41,38 +39,9 @@ void describe('AmplifyFunctionFactory', () => { }); void it('creates singleton function instance', () => { - const functionFactory = Func.fromDir({ - name: 'testFunc', - codePath: path.join('..', 'test-assets', 'test-lambda'), - }); + const functionFactory = defineFunction({}); const instance1 = functionFactory.getInstance(getInstanceProps); const instance2 = functionFactory.getInstance(getInstanceProps); assert.strictEqual(instance1, instance2); }); - - void it('executes build command from directory where constructor is used', async () => { - const commandExecutorMock = mock.fn(); - - // Casting to never is necessary because commandExecutor is a private method. - // TS yells that it's not a property on Func even though it is there - mock.method(Func, 'commandExecutor' as never, commandExecutorMock); - - ( - await Func.build({ - name: 'testFunc', - outDir: path.join('..', 'test-assets', 'test-lambda'), - buildCommand: 'test command', - }) - ).getInstance(getInstanceProps); - - assert.strictEqual(commandExecutorMock.mock.callCount(), 1); - assert.deepStrictEqual(commandExecutorMock.mock.calls[0].arguments, [ - 'test command', - { - cwd: fileURLToPath(new URL('../src', import.meta.url)), - stdio: 'inherit', - shell: 'bash', - }, - ]); - }); }); diff --git a/packages/backend-function/src/factory.ts b/packages/backend-function/src/factory.ts index c02600499c..76a8900a3f 100644 --- a/packages/backend-function/src/factory.ts +++ b/packages/backend-function/src/factory.ts @@ -2,137 +2,93 @@ import { ConstructContainerEntryGenerator, ConstructFactory, ConstructFactoryGetInstanceProps, + FunctionResources, + ResourceProvider, } from '@aws-amplify/plugin-types'; -import { - AmplifyFunctionProps, - AmplifyLambdaFunction, -} from '@aws-amplify/function-construct-alpha'; import { Construct } from 'constructs'; -import { execaCommand } from 'execa'; -import * as path from 'path'; -import { getCallerDirectory } from './get_caller_directory.js'; +import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'; + +/** + * Entry point for defining a function in the Amplify ecosystem + */ +export const defineFunction = (props: FunctionFactoryProps) => + new FunctionFactory(props); -export type AmplifyFunctionFactoryBaseProps = { +export type FunctionFactoryProps = { + /** + * A name for the function that is used to disambiguate it from other functions in the project. + * Defaults to the directory name in which this function is defined + */ + name?: string; /** - * A name for the function that is used to disambiguate it from other functions in the project + * The name of the function from the source code that is executed in the cloud + * Defaults to "handler" */ - name: string; + handler?: string; + /** + * The name of the file that contains the handler, relative to the location where `defineFunction` is called + * Defaults to "./handler.ts" + */ + relativeSourcePath?: string; }; -export type AmplifyFunctionFactoryBuildProps = AmplifyFunctionFactoryBaseProps & - Omit & { - /** - * The command to run that generates built function code. - * This command is run from the directory where this factory is called - */ - buildCommand: string; - /** - * The buildCommand is expected to place build artifacts at this location. - * This path can be relative or absolute. If relative, the absolute path is calculated based on the directory where this factory is called - */ - outDir: string; - }; - -export type AmplifyFunctionFactoryFromDirProps = - AmplifyFunctionFactoryBaseProps & - Omit & { - /** - * The location of the pre-built function code. - * Can be a directory or a .zip file. - * Can be a relative or absolute path. If relative, the absolute path is calculated based on the directory where this factory is called. - */ - codePath: string; - }; - -type AmplifyFunctionFactoryProps = AmplifyFunctionFactoryBaseProps & - AmplifyFunctionProps; - /** * Create Lambda functions in the context of an Amplify backend definition */ -export class AmplifyFunctionFactory - implements ConstructFactory -{ - // execaCommand is assigned to a static prop so that it can be mocked in tests - private static commandExecutor = execaCommand; - +export class FunctionFactory implements ConstructFactory { + private readonly placeholderDefaultName = 'placeholder-name'; private generator: ConstructContainerEntryGenerator; /** * Create a new AmplifyFunctionFactory */ - private constructor(private readonly props: AmplifyFunctionFactoryProps) {} - - /** - * Create a function from a directory that contains pre-built code - */ - static fromDir = ( - props: AmplifyFunctionFactoryFromDirProps - ): AmplifyFunctionFactory => { - const absoluteCodePath = path.isAbsolute(props.codePath) - ? props.codePath - : path.resolve(getCallerDirectory(new Error().stack), props.codePath); - return new AmplifyFunctionFactory({ - name: props.name, - absoluteCodePath, - runtime: props.runtime, - handler: props.handler, - }); - }; - - /** - * Create a function by executing a build command that places build artifacts at a specified location - * - * TODO: Investigate long-term function building strategy: https://github.com/aws-amplify/amplify-backend/issues/92 - */ - static build = async ( - props: AmplifyFunctionFactoryBuildProps - ): Promise => { - const importPath = getCallerDirectory(new Error().stack); - - await AmplifyFunctionFactory.commandExecutor(props.buildCommand, { - cwd: importPath, - stdio: 'inherit', - shell: 'bash', - }); - - const absoluteCodePath = path.isAbsolute(props.outDir) - ? props.outDir - : path.resolve(importPath, props.outDir); - - return new AmplifyFunctionFactory({ - name: props.name, - absoluteCodePath, - runtime: props.runtime, - handler: props.handler, - }); - }; + constructor(private readonly props: FunctionFactoryProps) {} /** * Creates an instance of AmplifyFunction within the provided Amplify context */ getInstance = ({ constructContainer, - }: ConstructFactoryGetInstanceProps): AmplifyLambdaFunction => { + }: ConstructFactoryGetInstanceProps): AmplifyFunction => { if (!this.generator) { - this.generator = new AmplifyFunctionGenerator(this.props); + this.generator = new FunctionGenerator(this.hydrateDefaults(this.props)); } - return constructContainer.getOrCompute( - this.generator - ) as AmplifyLambdaFunction; + return constructContainer.getOrCompute(this.generator) as AmplifyFunction; + }; + + private hydrateDefaults = ( + props: FunctionFactoryProps + ): HydratedFunctionProps => { + return { + name: props.name ?? this.placeholderDefaultName, + handler: props.handler ?? 'handler', + relativeSourcePath: props.relativeSourcePath ?? './handler.ts', + }; }; } -class AmplifyFunctionGenerator implements ConstructContainerEntryGenerator { +type HydratedFunctionProps = Required; + +class FunctionGenerator implements ConstructContainerEntryGenerator { readonly resourceGroupName = 'function'; - constructor(private readonly props: AmplifyFunctionFactoryProps) {} + constructor(private readonly props: HydratedFunctionProps) {} generateContainerEntry = (scope: Construct) => { - return new AmplifyLambdaFunction(scope, this.props.name, this.props); + return new AmplifyFunction(scope, this.props.name, this.props); }; } -/** - * Alias for AmplifyFunctionFactory - */ -export const Func = AmplifyFunctionFactory; +class AmplifyFunction + extends Construct + implements ResourceProvider +{ + readonly resources: FunctionResources; + constructor(scope: Construct, id: string, props: HydratedFunctionProps) { + super(scope, id); + const lambda = new NodejsFunction(scope, `${id}-lambda`, { + handler: props.handler, + entry: props.relativeSourcePath, + }); + this.resources.lambda = lambda; + } +} diff --git a/packages/backend-function/tsconfig.json b/packages/backend-function/tsconfig.json index 7ac631bb37..36aca79e32 100644 --- a/packages/backend-function/tsconfig.json +++ b/packages/backend-function/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "lib" }, "references": [ { "path": "../backend-output-storage" }, - { "path": "../function-construct" }, { "path": "../plugin-types" }, { "path": "../backend-platform-test-stubs" }, { "path": "../platform-core" } diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index db1eb4bfbf..039b5de54c 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -15,4 +15,4 @@ export { defineAuth } from '@aws-amplify/backend-auth'; export { defineStorage } from '@aws-amplify/backend-storage'; // function -export { Func } from '@aws-amplify/backend-function'; +export { defineFunction } from '@aws-amplify/backend-function'; diff --git a/packages/function-construct/.npmignore b/packages/function-construct/.npmignore deleted file mode 100644 index dbde1fb5db..0000000000 --- a/packages/function-construct/.npmignore +++ /dev/null @@ -1,14 +0,0 @@ -# Be very careful editing this file. It is crafted to work around [this issue](https://github.com/npm/npm/issues/4479) - -# First ignore everything -**/* - -# Then add back in transpiled js and ts declaration files -!lib/**/*.js -!lib/**/*.d.ts - -# Then ignore test js and ts declaration files -*.test.js -*.test.d.ts - -# This leaves us with including only js and ts declaration files of functional code diff --git a/packages/function-construct/API.md b/packages/function-construct/API.md deleted file mode 100644 index 34a1f63495..0000000000 --- a/packages/function-construct/API.md +++ /dev/null @@ -1,28 +0,0 @@ -## API Report File for "@aws-amplify/function-construct-alpha" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -import { AmplifyFunction } from '@aws-amplify/plugin-types'; -import { Construct } from 'constructs'; -import { FunctionResources } from '@aws-amplify/plugin-types'; -import { Runtime } from 'aws-cdk-lib/aws-lambda'; - -// @public (undocumented) -export type AmplifyFunctionProps = { - absoluteCodePath: string; - runtime?: Runtime; - handler?: string; -}; - -// @public -export class AmplifyLambdaFunction extends Construct implements AmplifyFunction { - constructor(scope: Construct, id: string, props: AmplifyFunctionProps); - // (undocumented) - readonly resources: FunctionResources; -} - -// (No @packageDocumentation comment for this package) - -``` diff --git a/packages/function-construct/CHANGELOG.md b/packages/function-construct/CHANGELOG.md deleted file mode 100644 index 9430b7399b..0000000000 --- a/packages/function-construct/CHANGELOG.md +++ /dev/null @@ -1,79 +0,0 @@ -# @aws-amplify/function-construct-alpha - -## 0.2.0 - -### Minor Changes - -- 47456c26: Store attribution metadata in stack descriptions - -### Patch Changes - -- b2b0c2da: force version bump -- 7296e9d9: Initial publish -- 7103735b: cdk lib dependency declaration -- 3c36ace9: Implement UserPool trigger config -- 36d93e46: add license to package.json -- 8f99476e: chore: upgrade aws-cdk to 2.103.0 -- 59f5ea24: chore: upgrade aws-cdk to 2.100.0 -- Updated dependencies [47456c26] -- Updated dependencies [ac3df080] -- Updated dependencies [0398b8e1] -- Updated dependencies [36d93e46] -- Updated dependencies [8f99476e] -- Updated dependencies [f75fa531] -- Updated dependencies [883d9da7] -- Updated dependencies [59f5ea24] - - @aws-amplify/backend-output-storage@0.2.0 - -## 0.2.0-alpha.7 - -### Minor Changes - -- 47456c26: Store attribution metadata in stack descriptions - -### Patch Changes - -- Updated dependencies [47456c26] - - @aws-amplify/backend-output-storage@0.2.0-alpha.6 - -## 0.1.1-alpha.6 - -### Patch Changes - -- 8f99476e: chore: upgrade aws-cdk to 2.103.0 - -## 0.1.1-alpha.5 - -### Patch Changes - -- 59f5ea24: chore: upgrade aws-cdk to 2.100.0 - -## 0.1.1-alpha.4 - -### Patch Changes - -- 7103735b: cdk lib dependency declaration - -## 0.1.1-alpha.3 - -### Patch Changes - -- 36d93e46: add license to package.json - -## 0.1.1-alpha.2 - -### Patch Changes - -- 3c36ace: Implement UserPool trigger config - -## 0.1.1-alpha.1 - -### Patch Changes - -- b2b0c2d: force version bump - -## 0.1.1-alpha.0 - -### Patch Changes - -- 7296e9d: Initial publish diff --git a/packages/function-construct/api-extractor.json b/packages/function-construct/api-extractor.json deleted file mode 100644 index 0f56de03f6..0000000000 --- a/packages/function-construct/api-extractor.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../api-extractor.base.json" -} diff --git a/packages/function-construct/package.json b/packages/function-construct/package.json deleted file mode 100644 index 575311cafb..0000000000 --- a/packages/function-construct/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@aws-amplify/function-construct-alpha", - "version": "0.2.0", - "type": "module", - "publishConfig": { - "access": "public" - }, - "exports": { - ".": { - "types": "./lib/index.d.ts", - "import": "./lib/index.js", - "require": "./lib/index.js" - } - }, - "types": "lib/index.d.ts", - "scripts": { - "update:api": "api-extractor run --local" - }, - "license": "Apache-2.0", - "dependencies": { - "@aws-amplify/backend-output-storage": "^0.2.0" - }, - "peerDependencies": { - "aws-cdk-lib": "^2.103.0", - "constructs": "^10.0.0" - } -} diff --git a/packages/function-construct/src/construct.test.ts b/packages/function-construct/src/construct.test.ts deleted file mode 100644 index b5755accf1..0000000000 --- a/packages/function-construct/src/construct.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { beforeEach, describe, it } from 'node:test'; -import { App, Stack } from 'aws-cdk-lib'; -import { Template } from 'aws-cdk-lib/assertions'; -import { AmplifyLambdaFunction } from './construct.js'; -import { Runtime } from 'aws-cdk-lib/aws-lambda'; -import { fileURLToPath } from 'url'; -import assert from 'node:assert'; - -const testCodePath = fileURLToPath( - new URL('../test-assets/test-lambda', import.meta.url) -); - -void describe('AmplifyFunction', () => { - let stack: Stack; - beforeEach(() => { - const app = new App(); - stack = new Stack(app); - }); - void it('creates lambda with specified runtime', () => { - new AmplifyLambdaFunction(stack, 'test', { - absoluteCodePath: testCodePath, - runtime: Runtime.JAVA_8, - }); - const template = Template.fromStack(stack); - template.hasResourceProperties('AWS::Lambda::Function', { - Runtime: 'java8', - }); - }); - - void it('creates lambda with default runtime', () => { - new AmplifyLambdaFunction(stack, 'test', { - absoluteCodePath: testCodePath, - }); - const template = Template.fromStack(stack); - template.hasResourceProperties('AWS::Lambda::Function', { - Runtime: 'nodejs18.x', - }); - }); - - void it('creates lambda with specified handler', () => { - new AmplifyLambdaFunction(stack, 'test', { - absoluteCodePath: testCodePath, - handler: 'test.main', - }); - const template = Template.fromStack(stack); - template.hasResourceProperties('AWS::Lambda::Function', { - Handler: 'test.main', - }); - }); - - void it('creates lambda with default handler', () => { - new AmplifyLambdaFunction(stack, 'test', { - absoluteCodePath: testCodePath, - }); - const template = Template.fromStack(stack); - template.hasResourceProperties('AWS::Lambda::Function', { - Handler: 'index.handler', - }); - }); - - void it('stores attribution data in stack', () => { - const app = new App(); - const stack = new Stack(app); - new AmplifyLambdaFunction(stack, 'testAuth', { - absoluteCodePath: testCodePath, - }); - - const template = Template.fromStack(stack); - assert.equal( - JSON.parse(template.toJSON().Description).stackType, - 'function-Lambda' - ); - }); -}); diff --git a/packages/function-construct/src/construct.ts b/packages/function-construct/src/construct.ts deleted file mode 100644 index 19167c510a..0000000000 --- a/packages/function-construct/src/construct.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Construct } from 'constructs'; -import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda'; -import { AmplifyFunction, FunctionResources } from '@aws-amplify/plugin-types'; -import { AttributionMetadataStorage } from '@aws-amplify/backend-output-storage'; -import { Stack } from 'aws-cdk-lib'; -import { fileURLToPath } from 'url'; - -// Be very careful editing this value. It is the string that is used to attribute stacks to Amplify Function in BI metrics -const functionStackType = 'function-Lambda'; - -export type AmplifyFunctionProps = { - absoluteCodePath: string; - runtime?: Runtime; - handler?: string; -}; - -/** - * Hello world construct implementation - */ -export class AmplifyLambdaFunction - extends Construct - implements AmplifyFunction -{ - readonly resources: FunctionResources; - /** - * Create a new AmplifyConstruct - */ - constructor(scope: Construct, id: string, props: AmplifyFunctionProps) { - super(scope, id); - - this.resources = { - lambda: new Function(this, `${id}LambdaFunction`, { - code: Code.fromAsset(props.absoluteCodePath), - runtime: props.runtime || Runtime.NODEJS_18_X, - handler: props.handler || 'index.handler', - }), - }; - - new AttributionMetadataStorage().storeAttributionMetadata( - Stack.of(this), - functionStackType, - fileURLToPath(new URL('../package.json', import.meta.url)) - ); - } -} diff --git a/packages/function-construct/src/index.ts b/packages/function-construct/src/index.ts deleted file mode 100644 index 9d1f8f790c..0000000000 --- a/packages/function-construct/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './construct.js'; diff --git a/packages/function-construct/test-assets/test-lambda/mock.txt b/packages/function-construct/test-assets/test-lambda/mock.txt deleted file mode 100644 index 29cc220aee..0000000000 --- a/packages/function-construct/test-assets/test-lambda/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/function-construct/tsconfig.json b/packages/function-construct/tsconfig.json deleted file mode 100644 index 74efb05dd0..0000000000 --- a/packages/function-construct/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { "rootDir": "src", "outDir": "lib" }, - "references": [{ "path": "../backend-output-storage" }] -} diff --git a/packages/function-construct/typedoc.json b/packages/function-construct/typedoc.json deleted file mode 100644 index 35fed2c958..0000000000 --- a/packages/function-construct/typedoc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "entryPoints": ["src/index.ts"] -} From 96a785a8dc7453f2b882bedcaedb843ef8d9bb4c Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 12:08:34 -0800 Subject: [PATCH 02/26] update package lock --- package-lock.json | 124 ++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 64 deletions(-) diff --git a/package-lock.json b/package-lock.json index 54a2aa8c25..72380a712c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1084,10 +1084,6 @@ "resolved": "packages/form-generator", "link": true }, - "node_modules/@aws-amplify/function-construct-alpha": { - "resolved": "packages/function-construct", - "link": true - }, "node_modules/@aws-amplify/graphql-api-construct": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/@aws-amplify/graphql-api-construct/-/graphql-api-construct-1.4.2.tgz", @@ -19997,12 +19993,12 @@ }, "packages/auth-construct": { "name": "@aws-amplify/auth-construct-alpha", - "version": "0.4.1", + "version": "0.4.2", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-schemas": "^0.4.0", - "@aws-amplify/backend-output-storage": "^0.2.4", - "@aws-amplify/plugin-types": "^0.4.1" + "@aws-amplify/backend-output-storage": "^0.2.6", + "@aws-amplify/plugin-types": "^0.4.2" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", @@ -20011,19 +20007,19 @@ }, "packages/backend": { "name": "@aws-amplify/backend", - "version": "0.5.4", + "version": "0.5.5", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/backend-auth": "^0.3.4", - "@aws-amplify/backend-data": "^0.8.1", - "@aws-amplify/backend-function": "^0.2.4", + "@aws-amplify/backend-auth": "^0.3.5", + "@aws-amplify/backend-data": "^0.8.2", + "@aws-amplify/backend-function": "^0.2.5", "@aws-amplify/backend-output-schemas": "^0.4.0", - "@aws-amplify/backend-output-storage": "^0.2.5", + "@aws-amplify/backend-output-storage": "^0.2.6", "@aws-amplify/backend-secret": "^0.3.1", - "@aws-amplify/backend-storage": "^0.3.0", + "@aws-amplify/backend-storage": "^0.3.1", "@aws-amplify/data-schema": "^0.12.9", - "@aws-amplify/platform-core": "^0.3.0", - "@aws-amplify/plugin-types": "^0.4.1", + "@aws-amplify/platform-core": "^0.3.1", + "@aws-amplify/plugin-types": "^0.4.2", "@aws-sdk/client-amplify": "^3.440.0" }, "devDependencies": { @@ -20037,16 +20033,16 @@ }, "packages/backend-auth": { "name": "@aws-amplify/backend-auth", - "version": "0.3.4", + "version": "0.3.5", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/auth-construct-alpha": "^0.4.1", - "@aws-amplify/backend-output-storage": "0.2.5", - "@aws-amplify/plugin-types": "^0.4.1" + "@aws-amplify/auth-construct-alpha": "^0.4.2", + "@aws-amplify/backend-output-storage": "0.2.6", + "@aws-amplify/plugin-types": "^0.4.2" }, "devDependencies": { - "@aws-amplify/backend-platform-test-stubs": "^0.3.0", - "@aws-amplify/platform-core": "^0.3.0" + "@aws-amplify/backend-platform-test-stubs": "^0.3.1", + "@aws-amplify/platform-core": "^0.3.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", @@ -20055,19 +20051,19 @@ }, "packages/backend-data": { "name": "@aws-amplify/backend-data", - "version": "0.8.1", + "version": "0.8.2", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-schemas": "^0.4.0", - "@aws-amplify/backend-output-storage": "0.2.5", + "@aws-amplify/backend-output-storage": "0.2.6", "@aws-amplify/data-construct": "^1.4.1", "@aws-amplify/data-schema-types": "^0.6.6", - "@aws-amplify/plugin-types": "^0.4.1" + "@aws-amplify/plugin-types": "^0.4.2" }, "devDependencies": { - "@aws-amplify/backend-platform-test-stubs": "^0.3.0", + "@aws-amplify/backend-platform-test-stubs": "^0.3.1", "@aws-amplify/data-schema": "^0.12.9", - "@aws-amplify/platform-core": "^0.3.0" + "@aws-amplify/platform-core": "^0.3.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", @@ -20076,11 +20072,11 @@ }, "packages/backend-deployer": { "name": "@aws-amplify/backend-deployer", - "version": "0.3.3", + "version": "0.3.4", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/platform-core": "^0.3.0", - "@aws-amplify/plugin-types": "^0.4.0", + "@aws-amplify/platform-core": "^0.3.1", + "@aws-amplify/plugin-types": "^0.4.2", "execa": "^7.2.0", "tsx": "^3.12.6" }, @@ -20091,17 +20087,16 @@ }, "packages/backend-function": { "name": "@aws-amplify/backend-function", - "version": "0.2.4", + "version": "0.2.5", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/backend-output-storage": "0.2.5", - "@aws-amplify/function-construct-alpha": "^0.2.0", - "@aws-amplify/plugin-types": "^0.4.1", + "@aws-amplify/backend-output-storage": "0.2.6", + "@aws-amplify/plugin-types": "^0.4.2", "execa": "^7.1.1" }, "devDependencies": { - "@aws-amplify/backend-platform-test-stubs": "^0.3.0", - "@aws-amplify/platform-core": "^0.3.0" + "@aws-amplify/backend-platform-test-stubs": "^0.3.1", + "@aws-amplify/platform-core": "^0.3.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", @@ -20113,7 +20108,7 @@ "version": "0.4.0", "license": "Apache-2.0", "devDependencies": { - "@aws-amplify/plugin-types": "0.4.1" + "@aws-amplify/plugin-types": "0.4.2" }, "peerDependencies": { "zod": "^3.21.4" @@ -20121,11 +20116,11 @@ }, "packages/backend-output-storage": { "name": "@aws-amplify/backend-output-storage", - "version": "0.2.5", + "version": "0.2.6", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-schemas": "^0.4.0", - "@aws-amplify/platform-core": "^0.3.0" + "@aws-amplify/platform-core": "^0.3.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1" @@ -20133,7 +20128,7 @@ }, "packages/backend-platform-test-stubs": { "name": "@aws-amplify/backend-platform-test-stubs", - "version": "0.3.0", + "version": "0.3.1", "license": "Apache-2.0", "dependencies": { "aws-cdk-lib": "^2.110.1", @@ -20155,16 +20150,16 @@ }, "packages/backend-storage": { "name": "@aws-amplify/backend-storage", - "version": "0.3.0", + "version": "0.3.1", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/backend-output-storage": "^0.2.5", - "@aws-amplify/plugin-types": "^0.4.0", - "@aws-amplify/storage-construct-alpha": "^0.2.1" + "@aws-amplify/backend-output-storage": "^0.2.6", + "@aws-amplify/plugin-types": "^0.4.2", + "@aws-amplify/storage-construct-alpha": "^0.2.3" }, "devDependencies": { - "@aws-amplify/backend-platform-test-stubs": "^0.3.0", - "@aws-amplify/platform-core": "^0.3.0" + "@aws-amplify/backend-platform-test-stubs": "^0.3.1", + "@aws-amplify/platform-core": "^0.3.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", @@ -20173,7 +20168,7 @@ }, "packages/cli": { "name": "@aws-amplify/backend-cli", - "version": "0.9.0", + "version": "0.9.1", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-schemas": "^0.4.0", @@ -20181,7 +20176,7 @@ "@aws-amplify/cli-core": "^0.2.0", "@aws-amplify/client-config": "^0.4.2", "@aws-amplify/deployed-backend-client": "^0.3.3", - "@aws-amplify/form-generator": "^0.5.0", + "@aws-amplify/form-generator": "^0.6.0", "@aws-amplify/model-generator": "^0.2.3", "@aws-amplify/platform-core": "^0.3.0", "@aws-amplify/sandbox": "^0.3.5", @@ -20372,11 +20367,11 @@ } }, "packages/create-amplify": { - "version": "0.3.7", + "version": "0.3.8", "license": "Apache-2.0", "dependencies": { "@aws-amplify/cli-core": "^0.2.0", - "@aws-amplify/platform-core": "0.3.0", + "@aws-amplify/platform-core": "0.3.1", "execa": "^7.2.0", "yargs": "^17.7.2" }, @@ -20503,7 +20498,7 @@ }, "packages/form-generator": { "name": "@aws-amplify/form-generator", - "version": "0.5.0", + "version": "0.6.0", "license": "Apache-2.0", "dependencies": { "@aws-amplify/appsync-modelgen-plugin": "^2.6.0", @@ -20523,6 +20518,7 @@ "packages/function-construct": { "name": "@aws-amplify/function-construct-alpha", "version": "0.2.0", + "extraneous": true, "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-storage": "^0.2.0" @@ -20534,16 +20530,16 @@ }, "packages/integration-tests": { "name": "@aws-amplify/integration-tests", - "version": "0.3.6", + "version": "0.3.7", "license": "Apache-2.0", "devDependencies": { - "@aws-amplify/backend": "0.5.4", - "@aws-amplify/backend-auth": "0.3.4", + "@aws-amplify/backend": "0.5.5", + "@aws-amplify/backend-auth": "0.3.5", "@aws-amplify/backend-secret": "^0.3.1", - "@aws-amplify/backend-storage": "0.3.0", + "@aws-amplify/backend-storage": "0.3.1", "@aws-amplify/client-config": "^0.4.0", "@aws-amplify/data-schema": "^0.12.9", - "@aws-amplify/platform-core": "^0.3.0", + "@aws-amplify/platform-core": "^0.3.1", "@aws-sdk/client-amplify": "^3.440.0", "@aws-sdk/client-cloudformation": "^3.421.0", "execa": "^8.0.1", @@ -20625,10 +20621,10 @@ }, "packages/platform-core": { "name": "@aws-amplify/platform-core", - "version": "0.3.0", + "version": "0.3.1", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/plugin-types": "^0.4.0", + "@aws-amplify/plugin-types": "^0.4.2", "@aws-sdk/client-sts": "3.445.0", "is-ci": "^3.0.1", "uuid": "9.0.1", @@ -21048,7 +21044,7 @@ }, "packages/plugin-types": { "name": "@aws-amplify/plugin-types", - "version": "0.4.1", + "version": "0.4.2", "license": "Apache-2.0", "peerDependencies": { "aws-cdk-lib": "^2.110.1", @@ -21057,15 +21053,15 @@ }, "packages/sandbox": { "name": "@aws-amplify/sandbox", - "version": "0.3.5", + "version": "0.3.6", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/backend-deployer": "0.3.3", + "@aws-amplify/backend-deployer": "0.3.4", "@aws-amplify/backend-secret": "^0.3.1", "@aws-amplify/cli-core": "^0.2.0", "@aws-amplify/client-config": "0.4.2", "@aws-amplify/deployed-backend-client": "^0.3.3", - "@aws-amplify/platform-core": "^0.3.0", + "@aws-amplify/platform-core": "^0.3.1", "@aws-sdk/client-cloudformation": "^3.421.0", "@aws-sdk/credential-providers": "^3.382.0", "@aws-sdk/types": "^3.378.0", @@ -21085,14 +21081,14 @@ }, "packages/storage-construct": { "name": "@aws-amplify/storage-construct-alpha", - "version": "0.2.2", + "version": "0.2.3", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-schemas": "^0.4.0", - "@aws-amplify/backend-output-storage": "^0.2.2" + "@aws-amplify/backend-output-storage": "^0.2.6" }, "devDependencies": { - "@aws-amplify/plugin-types": "^0.4.1" + "@aws-amplify/plugin-types": "^0.4.2" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", From 84bb93c8252b4f05ce2b422c3d3b3dc4586ad800 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 14:29:25 -0800 Subject: [PATCH 03/26] updating test cases --- packages/backend-function/src/factory.test.ts | 54 +++++++++++- packages/backend-function/src/factory.ts | 84 +++++++++++++------ .../src/test-assets/default-lambda/handler.ts | 7 ++ .../test-assets/default-lambda/resource.ts | 7 ++ .../test-assets/test-lambda/mock.txt | 2 - .../amplify/data/echo/handler.cjs | 7 ++ .../amplify/data/echo/mock.txt | 2 - .../amplify/data/resource.cjs | 6 +- .../amplify/func-src/handler.cjs | 7 ++ .../amplify/func-src/mock.txt | 2 - .../amplify/function.cjs | 7 +- .../amplify/data/echo/handler.ts | 7 ++ .../amplify/data/echo/mock.txt | 2 - .../amplify/data/resource.js | 6 +- .../amplify/func-src/handler.js | 7 ++ .../amplify/func-src/mock.txt | 2 - .../amplify/function.js | 7 +- .../amplify/data/echo/handler.ts | 7 ++ .../amplify/data/echo/mock.txt | 2 - .../amplify/data/resource.ts | 11 ++- .../amplify/func-src/handler.ts | 7 ++ .../amplify/func-src/mock.txt | 2 - .../amplify/function.ts | 7 +- .../amplify/data/api-auth/mock.txt | 2 - .../amplify/data/lambda_authorizer.ts | 7 ++ .../amplify/data/resource.ts | 8 +- .../plugin-types/src/function_resources.ts | 4 +- 27 files changed, 202 insertions(+), 71 deletions(-) create mode 100644 packages/backend-function/src/test-assets/default-lambda/handler.ts create mode 100644 packages/backend-function/src/test-assets/default-lambda/resource.ts delete mode 100644 packages/backend-function/test-assets/test-lambda/mock.txt create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs delete mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/mock.txt create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs delete mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/mock.txt create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.ts delete mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/mock.txt create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js delete mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/mock.txt create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts delete mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/mock.txt create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts delete mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/mock.txt delete mode 100644 packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/api-auth/mock.txt create mode 100644 packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts diff --git a/packages/backend-function/src/factory.test.ts b/packages/backend-function/src/factory.test.ts index c0a4c9fcce..28809ab46f 100644 --- a/packages/backend-function/src/factory.test.ts +++ b/packages/backend-function/src/factory.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, it } from 'node:test'; -import { defineFunction } from './factory.js'; import { App, Stack } from 'aws-cdk-lib'; import { ConstructFactoryGetInstanceProps } from '@aws-amplify/plugin-types'; import assert from 'node:assert'; @@ -8,6 +7,9 @@ import { ConstructContainerStub, StackResolverStub, } from '@aws-amplify/backend-platform-test-stubs'; +import { defaultLambda } from './test-assets/default-lambda/resource.js'; +import { Template } from 'aws-cdk-lib/assertions'; +import { defineFunction } from './factory.js'; const createStackAndSetContext = (): Stack => { const app = new App(); @@ -39,9 +41,57 @@ void describe('AmplifyFunctionFactory', () => { }); void it('creates singleton function instance', () => { - const functionFactory = defineFunction({}); + const functionFactory = defaultLambda; const instance1 = functionFactory.getInstance(getInstanceProps); const instance2 = functionFactory.getInstance(getInstanceProps); assert.strictEqual(instance1, instance2); }); + + void it('resolves default name and entry when no args specified', () => { + const functionFactory = defaultLambda; + const lambda = functionFactory.getInstance(getInstanceProps); + const template = Template.fromStack(Stack.of(lambda)); + template.resourceCountIs('AWS::Lambda::Function', 1); + template.hasResourceProperties('AWS::Lambda::Function', { + Handler: 'index.handler', + }); + const lambdaLogicalId = Object.keys( + template.findResources('AWS::Lambda::Function') + )[0]; + // eslint-disable-next-line spellcheck/spell-checker + assert.ok(lambdaLogicalId.includes('defaultlambda')); + }); + + void it('resolves default name when entry specified', () => { + const functionFactory = defineFunction({ + entry: './test-assets/default-lambda/handler.ts', + }); + const lambda = functionFactory.getInstance(getInstanceProps); + const template = Template.fromStack(Stack.of(lambda)); + template.resourceCountIs('AWS::Lambda::Function', 1); + template.hasResourceProperties('AWS::Lambda::Function', { + Handler: 'index.handler', + }); + const lambdaLogicalId = Object.keys( + template.findResources('AWS::Lambda::Function') + )[0]; + assert.ok(lambdaLogicalId.includes('handler')); + }); + + void it('uses name and entry that is explicitly specified', () => { + const functionFactory = defineFunction({ + entry: './test-assets/default-lambda/handler.ts', + name: 'myCoolLambda', + }); + const lambda = functionFactory.getInstance(getInstanceProps); + const template = Template.fromStack(Stack.of(lambda)); + template.resourceCountIs('AWS::Lambda::Function', 1); + template.hasResourceProperties('AWS::Lambda::Function', { + Handler: 'index.handler', + }); + const lambdaLogicalId = Object.keys( + template.findResources('AWS::Lambda::Function') + )[0]; + assert.ok(lambdaLogicalId.includes('myCoolLambda')); + }); }); diff --git a/packages/backend-function/src/factory.ts b/packages/backend-function/src/factory.ts index 76a8900a3f..8f970fa4cd 100644 --- a/packages/backend-function/src/factory.ts +++ b/packages/backend-function/src/factory.ts @@ -7,41 +7,47 @@ import { } from '@aws-amplify/plugin-types'; import { Construct } from 'constructs'; import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'; +import * as path from 'path'; +import { getCallerDirectory } from './get_caller_directory.js'; /** * Entry point for defining a function in the Amplify ecosystem */ -export const defineFunction = (props: FunctionFactoryProps) => - new FunctionFactory(props); +export const defineFunction = (props: FunctionFactoryProps = {}) => + new FunctionFactory(props, new Error().stack); export type FunctionFactoryProps = { /** - * A name for the function that is used to disambiguate it from other functions in the project. - * Defaults to the directory name in which this function is defined + * A name for the function. + * Defaults to the basename of the entry path if specified. + * If no entry is specified, defaults to the directory name in which this function is defined. + * + * Example: + * If entry is `./scheduled-db-backup.ts` the name will default to "scheduled-db-backup" + * If entry is not set and the function is defined in `amplify/functions/db-backup/resource.ts` the name will default to "db-backup" */ name?: string; /** - * The name of the function from the source code that is executed in the cloud - * Defaults to "handler" + * The path to the file that contains the function entry point. + * If this is a relative path, it is computed relative to the file where this function is defined + * + * Defaults to './handler.ts' */ - handler?: string; - /** - * The name of the file that contains the handler, relative to the location where `defineFunction` is called - * Defaults to "./handler.ts" - */ - relativeSourcePath?: string; + entry?: string; }; /** * Create Lambda functions in the context of an Amplify backend definition */ export class FunctionFactory implements ConstructFactory { - private readonly placeholderDefaultName = 'placeholder-name'; private generator: ConstructContainerEntryGenerator; /** * Create a new AmplifyFunctionFactory */ - constructor(private readonly props: FunctionFactoryProps) {} + constructor( + private readonly props: FunctionFactoryProps, + private readonly callerStack?: string + ) {} /** * Creates an instance of AmplifyFunction within the provided Amplify context @@ -50,20 +56,46 @@ export class FunctionFactory implements ConstructFactory { constructContainer, }: ConstructFactoryGetInstanceProps): AmplifyFunction => { if (!this.generator) { - this.generator = new FunctionGenerator(this.hydrateDefaults(this.props)); + this.generator = new FunctionGenerator(this.hydrateDefaults()); } return constructContainer.getOrCompute(this.generator) as AmplifyFunction; }; - private hydrateDefaults = ( - props: FunctionFactoryProps - ): HydratedFunctionProps => { + private hydrateDefaults = (): HydratedFunctionProps => { return { - name: props.name ?? this.placeholderDefaultName, - handler: props.handler ?? 'handler', - relativeSourcePath: props.relativeSourcePath ?? './handler.ts', + name: this.resolveName(), + entry: this.resolveEntry(), }; }; + + private resolveName = () => { + // If name is set explicitly, use that + if (this.props.name) { + return this.props.name; + } + // If entry is set, use the basename of the entry path + if (this.props.entry) { + return path.parse(this.props.entry).name; + } + + // Otherwise, use the directory name where the function is defined + return path.basename(getCallerDirectory(this.callerStack)); + }; + + private resolveEntry = () => { + // if entry is not set, default to handler.ts + if (!this.props.entry) { + return path.join(getCallerDirectory(this.callerStack), 'handler.ts'); + } + + // if entry is absolute use that + if (path.isAbsolute(this.props.entry)) { + return this.props.entry; + } + + // if entry is relative, compute with respect to the caller directory + return path.join(getCallerDirectory(this.callerStack), this.props.entry); + }; } type HydratedFunctionProps = Required; @@ -85,10 +117,10 @@ class AmplifyFunction readonly resources: FunctionResources; constructor(scope: Construct, id: string, props: HydratedFunctionProps) { super(scope, id); - const lambda = new NodejsFunction(scope, `${id}-lambda`, { - handler: props.handler, - entry: props.relativeSourcePath, - }); - this.resources.lambda = lambda; + this.resources = { + lambda: new NodejsFunction(scope, `${id}-lambda`, { + entry: props.entry, + }), + }; } } diff --git a/packages/backend-function/src/test-assets/default-lambda/handler.ts b/packages/backend-function/src/test-assets/default-lambda/handler.ts new file mode 100644 index 0000000000..f0176ba4b3 --- /dev/null +++ b/packages/backend-function/src/test-assets/default-lambda/handler.ts @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing defaults to `defineFunction` + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/backend-function/src/test-assets/default-lambda/resource.ts b/packages/backend-function/src/test-assets/default-lambda/resource.ts new file mode 100644 index 0000000000..bfa80c0e97 --- /dev/null +++ b/packages/backend-function/src/test-assets/default-lambda/resource.ts @@ -0,0 +1,7 @@ +import { defineFunction } from '../../factory.js'; + +/** + * Because the defineFunction() defaults depend on a specific file convention, + * we are defining a test asset here where the directory structure can be controlled + */ +export const defaultLambda = defineFunction(); diff --git a/packages/backend-function/test-assets/test-lambda/mock.txt b/packages/backend-function/test-assets/test-lambda/mock.txt deleted file mode 100644 index 29cc220aee..0000000000 --- a/packages/backend-function/test-assets/test-lambda/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs new file mode 100644 index 0000000000..a4349bc781 --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/mock.txt b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/mock.txt deleted file mode 100644 index 5e253db13e..0000000000 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/resource.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/resource.cjs index b43b5a1955..c0d0765e31 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/resource.cjs +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/resource.cjs @@ -1,6 +1,6 @@ 'use strict'; -const { Func, defineData } = require('@aws-amplify/backend'); +const { defineFunction, defineData } = require('@aws-amplify/backend'); const { myFunc } = require('../function.cjs'); @@ -23,9 +23,9 @@ const data = defineData({ reverse: myFunc, // Leaving explicit Func invocation here, // ensuring we can use functions not added to `defineBackend`. - echo: Func.fromDir({ + echo: defineFunction({ name: 'echoFunc', - codePath: './echo', + entry: './echo/handler.cjs', }), }, }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs new file mode 100644 index 0000000000..d03e589d74 --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/mock.txt b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/mock.txt deleted file mode 100644 index 29cc220aee..0000000000 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/function.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/function.cjs index 091b0fc78a..1e30c21fe9 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/function.cjs +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/function.cjs @@ -1,10 +1,9 @@ 'use strict'; -const { Func } = require('@aws-amplify/backend'); +const { defineFunction } = require('@aws-amplify/backend'); -const myFunc = Func.fromDir({ - name: 'testFunc', - codePath: './func-src', +const myFunc = defineFunction({ + entry: './func-src/handler.cjs', }); module.exports = { myFunc }; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.ts new file mode 100644 index 0000000000..6a08fdd75d --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.ts @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/mock.txt b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/mock.txt deleted file mode 100644 index 5e253db13e..0000000000 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js index eaf9de136d..0c63afbc21 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js @@ -1,4 +1,4 @@ -import { Func, defineData } from '@aws-amplify/backend'; +import { defineData, defineFunction } from '@aws-amplify/backend'; import { myFunc } from '../function'; const schema = ` @@ -20,9 +20,9 @@ export const data = defineData({ reverse: myFunc, // Leaving explicit Func invocation here, // ensuring we can use functions not added to `defineBackend`. - echo: Func.fromDir({ + echo: defineFunction({ name: 'echoFunc', - codePath: './echo', + entry: './echo/handler.ts', }), }, }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js new file mode 100644 index 0000000000..6a08fdd75d --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/mock.txt b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/mock.txt deleted file mode 100644 index 29cc220aee..0000000000 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js index ea270c6747..6a43bdbc65 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js @@ -1,6 +1,5 @@ -import { Func } from '@aws-amplify/backend'; +import { defineFunction } from '@aws-amplify/backend'; -export const myFunc = Func.fromDir({ - name: 'testFunc', - codePath: './func-src', +export const myFunc = defineFunction({ + entry: './func-src/handler.ts', }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts new file mode 100644 index 0000000000..6a08fdd75d --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/mock.txt b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/mock.txt deleted file mode 100644 index 5e253db13e..0000000000 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/resource.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/resource.ts index 9fb6b3e1f7..d0edc17f27 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/resource.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/resource.ts @@ -1,5 +1,10 @@ import { myFunc } from '../function.js'; -import { type ClientSchema, Func, a, defineData } from '@aws-amplify/backend'; +import { + type ClientSchema, + a, + defineData, + defineFunction, +} from '@aws-amplify/backend'; const schema = a.schema({ Todo: a @@ -38,9 +43,9 @@ export const data = defineData({ reverse: myFunc, // Leaving explicit Func invocation here, // ensuring we can use functions not added to `defineBackend`. - echo: Func.fromDir({ + echo: defineFunction({ name: 'echoFunc', - codePath: './echo', + entry: './echo/handler.ts', }), }, }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts new file mode 100644 index 0000000000..6a08fdd75d --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/mock.txt b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/mock.txt deleted file mode 100644 index 29cc220aee..0000000000 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts index ea270c6747..6a43bdbc65 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts @@ -1,6 +1,5 @@ -import { Func } from '@aws-amplify/backend'; +import { defineFunction } from '@aws-amplify/backend'; -export const myFunc = Func.fromDir({ - name: 'testFunc', - codePath: './func-src', +export const myFunc = defineFunction({ + entry: './func-src/handler.ts', }); diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/api-auth/mock.txt b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/api-auth/mock.txt deleted file mode 100644 index 29cc220aee..0000000000 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/api-auth/mock.txt +++ /dev/null @@ -1,2 +0,0 @@ -To test out creating a lambda we need a directory that simulates the lambda content. -Obviously this is not a real lambda, but it allows CDK synth to proceed. diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts new file mode 100644 index 0000000000..6a08fdd75d --- /dev/null +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts @@ -0,0 +1,7 @@ +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/resource.ts b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/resource.ts index 4a239517be..1adc7c73cc 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/resource.ts +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/resource.ts @@ -1,4 +1,4 @@ -import { Func, defineData } from '@aws-amplify/backend'; +import { defineData, defineFunction } from '@aws-amplify/backend'; export const data = defineData({ schema: /* GraphQL */ ` @@ -17,9 +17,9 @@ export const data = defineData({ authorizationModes: { defaultAuthorizationMode: 'lambda', lambdaAuthorizationMode: { - function: Func.fromDir({ - name: 'ApiAuth', - codePath: 'api-auth', + function: defineFunction({ + // eslint-disable-next-line spellcheck/spell-checker + entry: './lambda_authorizer.ts', }), timeToLiveInSeconds: 0, }, diff --git a/packages/plugin-types/src/function_resources.ts b/packages/plugin-types/src/function_resources.ts index 8e70d13a35..8734c04ee9 100644 --- a/packages/plugin-types/src/function_resources.ts +++ b/packages/plugin-types/src/function_resources.ts @@ -1,5 +1,5 @@ -import { Function as LambdaFunction } from 'aws-cdk-lib/aws-lambda'; +import { IFunction } from 'aws-cdk-lib/aws-lambda'; export type FunctionResources = { - lambda: LambdaFunction; + lambda: IFunction; }; From c5d94620d6903926d76ca301189f9ff7d0bf4de8 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 14:33:00 -0800 Subject: [PATCH 04/26] update snapshots --- packages/backend-function/src/factory.test.ts | 4 +- packages/backend-function/src/factory.ts | 6 +-- ...BranchName-branch-7d6f6c854a.template.json | 6 +-- ...d6f6c854aauth473E022C.nested.template.json | 2 +- ...d6f6c854adataE67321C2.nested.template.json | 2 +- ...BranchName-branch-7d6f6c854a.template.json | 4 +- ...d6f6c854adataE67321C2.nested.template.json | 2 +- ...BranchName-branch-7d6f6c854a.template.json | 22 +++++----- ...d6f6c854aauth473E022C.nested.template.json | 8 ++-- ...d6f6c854adataE67321C2.nested.template.json | 14 +++--- ...irectiveStack93F75775.nested.template.json | 16 +++---- ...c854afunctionDE2842E0.nested.template.json | 43 +++++++++++-------- ...6c854astorage16B83955.nested.template.json | 2 +- .../data/echo/{handler.ts => handler.js} | 0 .../amplify/data/resource.js | 2 +- .../amplify/function.js | 2 +- ...BranchName-branch-7d6f6c854a.template.json | 22 +++++----- ...d6f6c854aauth473E022C.nested.template.json | 8 ++-- ...d6f6c854adataE67321C2.nested.template.json | 14 +++--- ...irectiveStack93F75775.nested.template.json | 16 +++---- ...c854afunctionDE2842E0.nested.template.json | 43 +++++++++++-------- ...6c854astorage16B83955.nested.template.json | 2 +- ...BranchName-branch-7d6f6c854a.template.json | 18 ++++---- ...d6f6c854aauth473E022C.nested.template.json | 8 ++-- ...d6f6c854adataE67321C2.nested.template.json | 10 ++--- ...irectiveStack93F75775.nested.template.json | 8 ++-- ...c854afunctionDE2842E0.nested.template.json | 43 +++++++++++-------- ...6c854astorage16B83955.nested.template.json | 2 +- ...BranchName-branch-7d6f6c854a.template.json | 4 +- ...6c854astorage16B83955.nested.template.json | 2 +- ...BranchName-branch-7d6f6c854a.template.json | 10 ++--- ...d6f6c854adataE67321C2.nested.template.json | 6 +-- ...c854afunctionDE2842E0.nested.template.json | 26 ++++++----- ...BranchName-branch-7d6f6c854a.template.json | 4 +- ...d6f6c854adataE67321C2.nested.template.json | 2 +- 35 files changed, 207 insertions(+), 176 deletions(-) rename packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/{handler.ts => handler.js} (100%) diff --git a/packages/backend-function/src/factory.test.ts b/packages/backend-function/src/factory.test.ts index 28809ab46f..2b9828985a 100644 --- a/packages/backend-function/src/factory.test.ts +++ b/packages/backend-function/src/factory.test.ts @@ -64,7 +64,7 @@ void describe('AmplifyFunctionFactory', () => { void it('resolves default name when entry specified', () => { const functionFactory = defineFunction({ - entry: './test-assets/default-lambda/handler.ts', + entry: './test-assets/default-lambda/handler.js', }); const lambda = functionFactory.getInstance(getInstanceProps); const template = Template.fromStack(Stack.of(lambda)); @@ -80,7 +80,7 @@ void describe('AmplifyFunctionFactory', () => { void it('uses name and entry that is explicitly specified', () => { const functionFactory = defineFunction({ - entry: './test-assets/default-lambda/handler.ts', + entry: './test-assets/default-lambda/handler.js', name: 'myCoolLambda', }); const lambda = functionFactory.getInstance(getInstanceProps); diff --git a/packages/backend-function/src/factory.ts b/packages/backend-function/src/factory.ts index 8f970fa4cd..76536e989b 100644 --- a/packages/backend-function/src/factory.ts +++ b/packages/backend-function/src/factory.ts @@ -31,7 +31,7 @@ export type FunctionFactoryProps = { * The path to the file that contains the function entry point. * If this is a relative path, it is computed relative to the file where this function is defined * - * Defaults to './handler.ts' + * Defaults to './handler.js' */ entry?: string; }; @@ -83,9 +83,9 @@ export class FunctionFactory implements ConstructFactory { }; private resolveEntry = () => { - // if entry is not set, default to handler.ts + // if entry is not set, default to handler.js if (!this.props.entry) { - return path.join(getCallerDirectory(this.callerStack), 'handler.ts'); + return path.join(getCallerDirectory(this.callerStack), 'handler.js'); } // if entry is absolute use that diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 28df51e0cc..4361c8a007 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -368,7 +368,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/bc335d45f5f3eaaf9af9b95d772b50f0586653ea00c896d3996ad6d0782d4f65.json" + "/356837bc006efa614dd18d8e0821efb2f05db80aadc347e28db04bb2f6fe8bbd.json" ] ] } @@ -421,7 +421,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/aa5980fc1cfd00374e5224df874d7414086ec4f45288dc19e5fa63133e85c9a0.json" + "/91205c1519c983710f9e0aab22e73bae8d8372ba5a806b62f9ef8647eb33b14a.json" ] ] } diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json index 5d8b59a2c3..39d341963d 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.1\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.2\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", "Resources": { "amplifyAuthUserPool4BA7F805": { "Type": "AWS::Cognito::UserPool", diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index a1838ed660..12c816d30f 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703205067 + "Expires": 1703716371 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 44f24ad523..25678ec850 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/0af95f79425d31eb2f7a183c84eac6fef81f8a45d5d1895224e37a513e96e9ac.json" + "/c84a3ec2c156886a3c1bf56ef2ac113d1b900ddc3d7c79698bb684efd8bef145.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index c3d3cbc8d1..8aa806e5e4 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701217852 + "Expires": 1701729165 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index d1278d5bdb..bfcd9a76d3 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -391,10 +391,10 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" ] } }, @@ -414,7 +414,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/5c41ca256392cb9a9c61aa6cedbae9fa9a12c5927d30678087511cbea6557158.json" + "/601efeefc2f118029b329879a8fe6e995a9c76c75e5ee99588f1b68113b5436f.json" ] ] } @@ -441,7 +441,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/34165810aaf3ae2c8e32368cda1337ca1d9242720102a6e34bc223e4f3f4ac94.json" + "/5d08f8b126a912ddd1beed848e702e982ec4e47ec61b9b16587e3f69a05a178f.json" ] ] } @@ -468,7 +468,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/aae2917f7b6aa1fda37678972818215ed49129160005f03acfa90c29ad5f944f.json" + "/0d605cfcd689fb8650f00f193ce7572a75b06a8ccfaebc550876e3be9e352075.json" ] ] } @@ -504,16 +504,16 @@ "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthIdentityPool7404D50ERef" ] }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" ] }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" ] } }, @@ -533,7 +533,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/297077e3e6a1808350dfa1c8959f7f7335d51bd57c6bfbccc629f3ddb2e57d7b.json" + "/38d65f8333e6b54dd31e1d08c25bfacf5d46103d4d3968f5cc433339bb5213a3.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json index da71ef18dd..100298eab8 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.1\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.2\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", "Resources": { "SecretFetcherResourceProviderLambdaServiceRole5ABAF823": { "Type": "AWS::IAM::Role", @@ -316,7 +316,7 @@ "EmailVerificationSubject": "Verify your new account", "LambdaConfig": { "PostConfirmation": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" } }, "Policies": { @@ -362,7 +362,7 @@ "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, "Principal": "cognito-idp.amazonaws.com", "SourceArn": { @@ -644,7 +644,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 707307fd1a..729291545d 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -163,8 +163,8 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataGraphQLAPI8E80FACEApiId": { "Fn::GetAtt": [ @@ -178,8 +178,8 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthunauthenticatedUserRoleF922AD28Ref": { "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthunauthenticatedUserRoleF922AD28Ref" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" } }, "TemplateURL": { @@ -198,7 +198,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/390aa9db25a635decfe8354f0dd4e83f6cfe506d71adfd3998181733a678ed01.json" + "/0848bc21a07a9344b4254cf3c2499684d7ae926068bb57f946e7ce996d0e4d0b.json" ] ] } @@ -606,10 +606,10 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthIdentityPool7404D50ERef": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json index 581f089885..15e925d2cc 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json @@ -41,14 +41,14 @@ "Effect": "Allow", "Resource": [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, { "Fn::Join": [ "", [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, ":*" ] @@ -75,7 +75,7 @@ }, "LambdaConfig": { "LambdaFunctionArn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" } }, "Name": "ReverseLambdaDataSource", @@ -188,14 +188,14 @@ "Effect": "Allow", "Resource": [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, { "Fn::Join": [ "", [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, ":*" ] @@ -222,7 +222,7 @@ }, "LambdaConfig": { "LambdaFunctionArn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" } }, "Name": "EchoLambdaDataSource", @@ -310,7 +310,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" }, "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataGraphQLAPI8E80FACEApiId": { @@ -322,7 +322,7 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthunauthenticatedUserRoleF922AD28Ref": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Type": "String" } } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 94c1ca1f3b..48c3013a26 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -1,7 +1,6 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.0\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Resources": { - "testFunctestFuncLambdaFunctionServiceRole09E19D41": { + "handlerlambdaServiceRole46D7AF61": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -32,29 +31,34 @@ ] } }, - "testFunctestFuncLambdaFunction419C520E": { + "handlerlambdaE29D1580": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "d089e71db3f5da301e806bb05088811eb3edc37a581c5ba6d5d0724ec2312d2d.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "testFunctestFuncLambdaFunctionServiceRole09E19D41", + "handlerlambdaServiceRole46D7AF61", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "testFunctestFuncLambdaFunctionServiceRole09E19D41" + "handlerlambdaServiceRole46D7AF61" ] }, - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459": { + "echoFunclambdaServiceRoleF37965D7": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -85,42 +89,47 @@ ] } }, - "echoFuncechoFuncLambdaFunction08680056": { + "echoFunclambdaE17DCA46": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "e03749374a96d64aa843a04ee69955bfea3fb2446ca547a3609866ba406145fa.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459", + "echoFunclambdaServiceRoleF37965D7", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459" + "echoFunclambdaServiceRoleF37965D7" ] } }, "Outputs": { - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Value": { "Fn::GetAtt": [ - "testFunctestFuncLambdaFunction419C520E", + "handlerlambdaE29D1580", "Arn" ] } }, - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Value": { "Fn::GetAtt": [ - "echoFuncechoFuncLambdaFunction08680056", + "echoFunclambdaE17DCA46", "Arn" ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json index a89c3730fa..194423b7e3 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.2\",\"stackType\":\"storage-S3\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.3\",\"stackType\":\"storage-S3\",\"metadata\":{}}", "Resources": { "amplifyStorageamplifyStorageBucketC2F702CD": { "Type": "AWS::S3::Bucket", diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.js similarity index 100% rename from packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.ts rename to packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.js diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js index 0c63afbc21..3bf17f3578 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/resource.js @@ -22,7 +22,7 @@ export const data = defineData({ // ensuring we can use functions not added to `defineBackend`. echo: defineFunction({ name: 'echoFunc', - entry: './echo/handler.ts', + entry: './echo/handler.js', }), }, }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js index 6a43bdbc65..3c8b2a4840 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/function.js @@ -1,5 +1,5 @@ import { defineFunction } from '@aws-amplify/backend'; export const myFunc = defineFunction({ - entry: './func-src/handler.ts', + entry: './func-src/handler.js', }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index d1278d5bdb..06b72df5b2 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -391,10 +391,10 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" ] } }, @@ -414,7 +414,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/5c41ca256392cb9a9c61aa6cedbae9fa9a12c5927d30678087511cbea6557158.json" + "/601efeefc2f118029b329879a8fe6e995a9c76c75e5ee99588f1b68113b5436f.json" ] ] } @@ -441,7 +441,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/34165810aaf3ae2c8e32368cda1337ca1d9242720102a6e34bc223e4f3f4ac94.json" + "/b0b7029888764861a5d4be394bc4b5fc7e7973ce21e25adf025d0a9b4c63985a.json" ] ] } @@ -468,7 +468,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/aae2917f7b6aa1fda37678972818215ed49129160005f03acfa90c29ad5f944f.json" + "/0d605cfcd689fb8650f00f193ce7572a75b06a8ccfaebc550876e3be9e352075.json" ] ] } @@ -504,16 +504,16 @@ "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthIdentityPool7404D50ERef" ] }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" ] }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" ] } }, @@ -533,7 +533,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/297077e3e6a1808350dfa1c8959f7f7335d51bd57c6bfbccc629f3ddb2e57d7b.json" + "/38d65f8333e6b54dd31e1d08c25bfacf5d46103d4d3968f5cc433339bb5213a3.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json index da71ef18dd..100298eab8 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.1\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.2\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", "Resources": { "SecretFetcherResourceProviderLambdaServiceRole5ABAF823": { "Type": "AWS::IAM::Role", @@ -316,7 +316,7 @@ "EmailVerificationSubject": "Verify your new account", "LambdaConfig": { "PostConfirmation": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" } }, "Policies": { @@ -362,7 +362,7 @@ "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, "Principal": "cognito-idp.amazonaws.com", "SourceArn": { @@ -644,7 +644,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 707307fd1a..729291545d 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -163,8 +163,8 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataGraphQLAPI8E80FACEApiId": { "Fn::GetAtt": [ @@ -178,8 +178,8 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthunauthenticatedUserRoleF922AD28Ref": { "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthunauthenticatedUserRoleF922AD28Ref" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" } }, "TemplateURL": { @@ -198,7 +198,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/390aa9db25a635decfe8354f0dd4e83f6cfe506d71adfd3998181733a678ed01.json" + "/0848bc21a07a9344b4254cf3c2499684d7ae926068bb57f946e7ce996d0e4d0b.json" ] ] } @@ -606,10 +606,10 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthIdentityPool7404D50ERef": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json index 581f089885..15e925d2cc 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json @@ -41,14 +41,14 @@ "Effect": "Allow", "Resource": [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, { "Fn::Join": [ "", [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, ":*" ] @@ -75,7 +75,7 @@ }, "LambdaConfig": { "LambdaFunctionArn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" } }, "Name": "ReverseLambdaDataSource", @@ -188,14 +188,14 @@ "Effect": "Allow", "Resource": [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, { "Fn::Join": [ "", [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, ":*" ] @@ -222,7 +222,7 @@ }, "LambdaConfig": { "LambdaFunctionArn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" } }, "Name": "EchoLambdaDataSource", @@ -310,7 +310,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" }, "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataGraphQLAPI8E80FACEApiId": { @@ -322,7 +322,7 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthunauthenticatedUserRoleF922AD28Ref": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Type": "String" } } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 94c1ca1f3b..96efd91474 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -1,7 +1,6 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.0\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Resources": { - "testFunctestFuncLambdaFunctionServiceRole09E19D41": { + "handlerlambdaServiceRole46D7AF61": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -32,29 +31,34 @@ ] } }, - "testFunctestFuncLambdaFunction419C520E": { + "handlerlambdaE29D1580": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "16d90594449c1ff1bf24d95ed8f9b9c32dc0c9ae124fc88282b693281484614e.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "testFunctestFuncLambdaFunctionServiceRole09E19D41", + "handlerlambdaServiceRole46D7AF61", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "testFunctestFuncLambdaFunctionServiceRole09E19D41" + "handlerlambdaServiceRole46D7AF61" ] }, - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459": { + "echoFunclambdaServiceRoleF37965D7": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -85,42 +89,47 @@ ] } }, - "echoFuncechoFuncLambdaFunction08680056": { + "echoFunclambdaE17DCA46": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "f6288cec07233727491613f608871e0691909e78729aa27cea27f728303f9190.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459", + "echoFunclambdaServiceRoleF37965D7", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459" + "echoFunclambdaServiceRoleF37965D7" ] } }, "Outputs": { - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Value": { "Fn::GetAtt": [ - "testFunctestFuncLambdaFunction419C520E", + "handlerlambdaE29D1580", "Arn" ] } }, - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Value": { "Fn::GetAtt": [ - "echoFuncechoFuncLambdaFunction08680056", + "echoFunclambdaE17DCA46", "Arn" ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json index a89c3730fa..194423b7e3 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.2\",\"stackType\":\"storage-S3\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.3\",\"stackType\":\"storage-S3\",\"metadata\":{}}", "Resources": { "amplifyStorageamplifyStorageBucketC2F702CD": { "Type": "AWS::S3::Bucket", diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index b1aa37e401..a773f463db 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -400,10 +400,10 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" ] } }, @@ -423,7 +423,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/5c41ca256392cb9a9c61aa6cedbae9fa9a12c5927d30678087511cbea6557158.json" + "/601efeefc2f118029b329879a8fe6e995a9c76c75e5ee99588f1b68113b5436f.json" ] ] } @@ -450,7 +450,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/34165810aaf3ae2c8e32368cda1337ca1d9242720102a6e34bc223e4f3f4ac94.json" + "/1342fede173b09c6ed9e98f0c7dd50367fd5591d283c908897425da65ce6067e.json" ] ] } @@ -477,7 +477,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/aae2917f7b6aa1fda37678972818215ed49129160005f03acfa90c29ad5f944f.json" + "/0d605cfcd689fb8650f00f193ce7572a75b06a8ccfaebc550876e3be9e352075.json" ] ] } @@ -513,10 +513,10 @@ "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthIdentityPool7404D50ERef" ] }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" ] } }, @@ -536,7 +536,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/8cb0cb7e2fea755b319e74e97fe0b43998c9c837960f4b83af9a7c43f039b86c.json" + "/00ee6dd686adb50dd5e21768ccb0d91e9dba03c63dc82a8d4d87dcea2ad8123e.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json index da71ef18dd..100298eab8 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.1\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.4.2\",\"stackType\":\"auth-Cognito\",\"metadata\":{}}", "Resources": { "SecretFetcherResourceProviderLambdaServiceRole5ABAF823": { "Type": "AWS::IAM::Role", @@ -316,7 +316,7 @@ "EmailVerificationSubject": "Verify your new account", "LambdaConfig": { "PostConfirmation": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" } }, "Policies": { @@ -362,7 +362,7 @@ "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" }, "Principal": "cognito-idp.amazonaws.com", "SourceArn": { @@ -644,7 +644,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index a7cd02bcde..69190e4c97 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703205062 + "Expires": 1703716369 } }, "amplifyDataGraphQLAPINONEDS684BF699": { @@ -176,8 +176,8 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataGraphQLAPI8E80FACEApiId": { "Fn::GetAtt": [ @@ -214,7 +214,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/26f20f3fc00373eb0d67d7c89d1f8dda3f8bebbb3e1550d70bd6d126da6d6730.json" + "/313ef813581ce8a50e6465ec2bcbf54abdeeb5fa9a6b2b43d7c11b6989adeb41.json" ] ] } @@ -622,7 +622,7 @@ "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854aauthNestedStackauthNestedStackResource462F2942OutputsamplifytestAppIdtestBranchNamebranch7d6f6c854aauthamplifyAuthIdentityPool7404D50ERef": { "Type": "String" }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json index 7a431ffe39..a841c1bdda 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataFunctionDirectiveStack93F75775.nested.template.json @@ -41,14 +41,14 @@ "Effect": "Allow", "Resource": [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, { "Fn::Join": [ "", [ { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" }, ":*" ] @@ -75,7 +75,7 @@ }, "LambdaConfig": { "LambdaFunctionArn": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn" } }, "Name": "EchoLambdaDataSource", @@ -186,7 +186,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Type": "String" }, "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854adataamplifyDataGraphQLAPI8E80FACEApiId": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 94c1ca1f3b..45f8e4d367 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -1,7 +1,6 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.0\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Resources": { - "testFunctestFuncLambdaFunctionServiceRole09E19D41": { + "handlerlambdaServiceRole46D7AF61": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -32,29 +31,34 @@ ] } }, - "testFunctestFuncLambdaFunction419C520E": { + "handlerlambdaE29D1580": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "bc825239cb5be3934835f8041751aad6fb477a5a32260deb5073387df8b8d05b.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "testFunctestFuncLambdaFunctionServiceRole09E19D41", + "handlerlambdaServiceRole46D7AF61", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "testFunctestFuncLambdaFunctionServiceRole09E19D41" + "handlerlambdaServiceRole46D7AF61" ] }, - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459": { + "echoFunclambdaServiceRoleF37965D7": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -85,42 +89,47 @@ ] } }, - "echoFuncechoFuncLambdaFunction08680056": { + "echoFunclambdaE17DCA46": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "2d509b0ca61ebd56ec06852b7ebfc7e84217917bb5b62bba1d625938f9b1ec53.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459", + "echoFunclambdaServiceRoleF37965D7", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "echoFuncechoFuncLambdaFunctionServiceRoleE30E6459" + "echoFunclambdaServiceRoleF37965D7" ] } }, "Outputs": { - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctiontestFunctestFuncLambdaFunction675DD8C2Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { "Value": { "Fn::GetAtt": [ - "testFunctestFuncLambdaFunction419C520E", + "handlerlambdaE29D1580", "Arn" ] } }, - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFuncechoFuncLambdaFunctionCC7FF4D5Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionechoFunclambda1F2D9982Arn": { "Value": { "Fn::GetAtt": [ - "echoFuncechoFuncLambdaFunction08680056", + "echoFunclambdaE17DCA46", "Arn" ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json index a89c3730fa..194423b7e3 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.2\",\"stackType\":\"storage-S3\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.3\",\"stackType\":\"storage-S3\",\"metadata\":{}}", "Resources": { "amplifyStorageamplifyStorageBucketC2F702CD": { "Type": "AWS::S3::Bucket", diff --git a/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 6b6e5f9acf..a3c3041a35 100644 --- a/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -266,7 +266,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/aae2917f7b6aa1fda37678972818215ed49129160005f03acfa90c29ad5f944f.json" + "/0d605cfcd689fb8650f00f193ce7572a75b06a8ccfaebc550876e3be9e352075.json" ] ] } diff --git a/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json b/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json index a89c3730fa..194423b7e3 100644 --- a/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json +++ b/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854astorage16B83955.nested.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.2\",\"stackType\":\"storage-S3\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.3\",\"stackType\":\"storage-S3\",\"metadata\":{}}", "Resources": { "amplifyStorageamplifyStorageBucketC2F702CD": { "Type": "AWS::S3::Bucket", diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index fd607bc6ee..18972070cb 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -295,10 +295,10 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionApiAuthApiAuthLambdaFunctionCFF4ED65Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionlambdaauthorizerlambdaD2057200Arn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionApiAuthApiAuthLambdaFunctionCFF4ED65Arn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionlambdaauthorizerlambdaD2057200Arn" ] } }, @@ -318,7 +318,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/05251eaf9c7e228248013be4382298454e4222263c0e996131da678f06a468b3.json" + "/71a55e17a82505995ebb0e05260381c86a3b163df1525f23e731eb7a878fdaf6.json" ] ] } @@ -345,7 +345,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/1d9ba3324a466e898f90197e6412b5464de952663cd0619bbafedc38be06132d.json" + "/f0959cfa9ae54417a52a7f48a64f7f9b3fa5071d067365cd7e99004a2ff8344a.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index c68287826f..83e26f5f64 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -21,7 +21,7 @@ "LambdaAuthorizerConfig": { "AuthorizerResultTtlInSeconds": 0, "AuthorizerUri": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionApiAuthApiAuthLambdaFunctionCFF4ED65Arn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionlambdaauthorizerlambdaD2057200Arn" }, "IdentityValidationExpression": "" }, @@ -51,7 +51,7 @@ "ApiId" ] }, - "Expires": 1703205064 + "Expires": 1703716370 } }, "amplifyDataGraphQLAPINONEDS684BF699": { @@ -553,7 +553,7 @@ ], "Description": "Enable server side encryption powered by KMS." }, - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionApiAuthApiAuthLambdaFunctionCFF4ED65Arn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionlambdaauthorizerlambdaD2057200Arn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 976873710c..3dfa775cf8 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -1,7 +1,6 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.2.0\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Resources": { - "ApiAuthApiAuthLambdaFunctionServiceRole568E246E": { + "lambdaauthorizerlambdaServiceRoleCF35E55A": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -32,35 +31,40 @@ ] } }, - "ApiAuthApiAuthLambdaFunctionF84061EE": { + "lambdaauthorizerlambda4ACE2410": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "efe12e580179d925ecc56ede6195533f23db3a8e887169b63ecb5cc644193f2b.zip" + "S3Key": "47989b53bbcbba7ae3b7e09009d89dd2051eb334b2ff3ae9c3ad6eb98af704da.zip" + }, + "Environment": { + "Variables": { + "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" + } }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "ApiAuthApiAuthLambdaFunctionServiceRole568E246E", + "lambdaauthorizerlambdaServiceRoleCF35E55A", "Arn" ] }, - "Runtime": "nodejs18.x" + "Runtime": "nodejs16.x" }, "DependsOn": [ - "ApiAuthApiAuthLambdaFunctionServiceRole568E246E" + "lambdaauthorizerlambdaServiceRoleCF35E55A" ] }, - "ApiAuthApiAuthLambdaFunctionappsyncauthinvokeC187D22A": { + "lambdaauthorizerlambdaappsyncauthinvoke93C85899": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { "Fn::GetAtt": [ - "ApiAuthApiAuthLambdaFunctionF84061EE", + "lambdaauthorizerlambda4ACE2410", "Arn" ] }, @@ -69,10 +73,10 @@ } }, "Outputs": { - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionApiAuthApiAuthLambdaFunctionCFF4ED65Arn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionlambdaauthorizerlambdaD2057200Arn": { "Value": { "Fn::GetAtt": [ - "ApiAuthApiAuthLambdaFunctionF84061EE", + "lambdaauthorizerlambda4ACE2410", "Arn" ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index b5d4fbddea..30fc0f7def 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -1,5 +1,5 @@ { - "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.4\",\"stackType\":\"root\",\"metadata\":{}}", + "Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"AmplifyPipelineDeploy\",\"createdWith\":\"0.5.5\",\"stackType\":\"root\",\"metadata\":{}}", "Metadata": { "AWS::Amplify::Platform": { "version": "1", @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/426bd279acc51329d993502bd4f9aad03681287559c6b5c29cf4e4d8571e3f46.json" + "/2e55219172eaff222881c076e1086534ebde36cc2661150b5a5d54b692326cd4.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 5f702208c6..5631be4d6b 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701217866 + "Expires": 1701729170 } }, "amplifyDataGraphQLAPINONEDS684BF699": { From 22a3f0f11a26c7591d1f44d2aec87130fe00e401 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 14:35:51 -0800 Subject: [PATCH 05/26] update api extract --- packages/backend-function/API.md | 36 +++++++++++++------------------- packages/backend/API.md | 6 +++--- packages/plugin-types/API.md | 4 ++-- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/packages/backend-function/API.md b/packages/backend-function/API.md index 4bb4a858a8..e52c7219a7 100644 --- a/packages/backend-function/API.md +++ b/packages/backend-function/API.md @@ -4,37 +4,29 @@ ```ts -import { AmplifyFunctionProps } from '@aws-amplify/function-construct-alpha'; -import { AmplifyLambdaFunction } from '@aws-amplify/function-construct-alpha'; +import { Construct } from 'constructs'; import { ConstructFactory } from '@aws-amplify/plugin-types'; import { ConstructFactoryGetInstanceProps } from '@aws-amplify/plugin-types'; +import { FunctionResources } from '@aws-amplify/plugin-types'; +import { ResourceProvider } from '@aws-amplify/plugin-types'; // @public -export class AmplifyFunctionFactory implements ConstructFactory { - static build: (props: AmplifyFunctionFactoryBuildProps) => Promise; - static fromDir: (props: AmplifyFunctionFactoryFromDirProps) => AmplifyFunctionFactory; - getInstance: ({ constructContainer, }: ConstructFactoryGetInstanceProps) => AmplifyLambdaFunction; -} +export const defineFunction: (props?: FunctionFactoryProps) => FunctionFactory; -// @public (undocumented) -export type AmplifyFunctionFactoryBaseProps = { - name: string; -}; - -// @public (undocumented) -export type AmplifyFunctionFactoryBuildProps = AmplifyFunctionFactoryBaseProps & Omit & { - buildCommand: string; - outDir: string; -}; +// Warning: (ae-forgotten-export) The symbol "AmplifyFunction" needs to be exported by the entry point index.d.ts +// +// @public +export class FunctionFactory implements ConstructFactory { + constructor(props: FunctionFactoryProps, callerStack?: string | undefined); + getInstance: ({ constructContainer, }: ConstructFactoryGetInstanceProps) => AmplifyFunction; +} // @public (undocumented) -export type AmplifyFunctionFactoryFromDirProps = AmplifyFunctionFactoryBaseProps & Omit & { - codePath: string; +export type FunctionFactoryProps = { + name?: string; + entry?: string; }; -// @public -export const Func: typeof AmplifyFunctionFactory; - // (No @packageDocumentation comment for this package) ``` diff --git a/packages/backend/API.md b/packages/backend/API.md index 1a7e111cc4..edd546358d 100644 --- a/packages/backend/API.md +++ b/packages/backend/API.md @@ -11,8 +11,8 @@ import { Construct } from 'constructs'; import { ConstructFactory } from '@aws-amplify/plugin-types'; import { defineAuth } from '@aws-amplify/backend-auth'; import { defineData } from '@aws-amplify/backend-data'; +import { defineFunction } from '@aws-amplify/backend-function'; import { defineStorage } from '@aws-amplify/backend-storage'; -import { Func } from '@aws-amplify/backend-function'; import { Stack } from 'aws-cdk-lib'; export { a } @@ -34,9 +34,9 @@ export const defineBackend: BackendSecret; diff --git a/packages/plugin-types/API.md b/packages/plugin-types/API.md index 743398be43..8b5e78025d 100644 --- a/packages/plugin-types/API.md +++ b/packages/plugin-types/API.md @@ -9,7 +9,7 @@ import { CfnIdentityPoolRoleAttachment } from 'aws-cdk-lib/aws-cognito'; import { CfnUserPool } from 'aws-cdk-lib/aws-cognito'; import { CfnUserPoolClient } from 'aws-cdk-lib/aws-cognito'; import { Construct } from 'constructs'; -import { Function as Function_2 } from 'aws-cdk-lib/aws-lambda'; +import { IFunction } from 'aws-cdk-lib/aws-lambda'; import { IRole } from 'aws-cdk-lib/aws-iam'; import { IUserPool } from 'aws-cdk-lib/aws-cognito'; import { IUserPoolClient } from 'aws-cdk-lib/aws-cognito'; @@ -115,7 +115,7 @@ export type DeploymentType = 'branch' | 'sandbox'; // @public (undocumented) export type FunctionResources = { - lambda: Function_2; + lambda: IFunction; }; // @public From e3985a7967fcf200cbb2a360c589014149bf5ad8 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 14:37:37 -0800 Subject: [PATCH 06/26] add changeset --- .changeset/few-carpets-search.md | 5 +++++ .changeset/mighty-rockets-shake.md | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/few-carpets-search.md create mode 100644 .changeset/mighty-rockets-shake.md diff --git a/.changeset/few-carpets-search.md b/.changeset/few-carpets-search.md new file mode 100644 index 0000000000..20381169c7 --- /dev/null +++ b/.changeset/few-carpets-search.md @@ -0,0 +1,5 @@ +--- +'@aws-amplify/backend-function': minor +--- + +Initial implementation of new 'defineFunction' entry point diff --git a/.changeset/mighty-rockets-shake.md b/.changeset/mighty-rockets-shake.md new file mode 100644 index 0000000000..d2cda1585e --- /dev/null +++ b/.changeset/mighty-rockets-shake.md @@ -0,0 +1,7 @@ +--- +'create-amplify': patch +'@aws-amplify/plugin-types': patch +'@aws-amplify/backend': patch +--- + +Expose new `defineFunction` interface From 052e87e3c8353ac867405421228701df48a827a4 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 14:45:29 -0800 Subject: [PATCH 07/26] fix api --- packages/backend-function/API.md | 11 +---------- packages/backend-function/src/factory.ts | 6 ++++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/backend-function/API.md b/packages/backend-function/API.md index e52c7219a7..052bc29269 100644 --- a/packages/backend-function/API.md +++ b/packages/backend-function/API.md @@ -6,20 +6,11 @@ import { Construct } from 'constructs'; import { ConstructFactory } from '@aws-amplify/plugin-types'; -import { ConstructFactoryGetInstanceProps } from '@aws-amplify/plugin-types'; import { FunctionResources } from '@aws-amplify/plugin-types'; import { ResourceProvider } from '@aws-amplify/plugin-types'; // @public -export const defineFunction: (props?: FunctionFactoryProps) => FunctionFactory; - -// Warning: (ae-forgotten-export) The symbol "AmplifyFunction" needs to be exported by the entry point index.d.ts -// -// @public -export class FunctionFactory implements ConstructFactory { - constructor(props: FunctionFactoryProps, callerStack?: string | undefined); - getInstance: ({ constructContainer, }: ConstructFactoryGetInstanceProps) => AmplifyFunction; -} +export const defineFunction: (props?: FunctionFactoryProps) => ConstructFactory>; // @public (undocumented) export type FunctionFactoryProps = { diff --git a/packages/backend-function/src/factory.ts b/packages/backend-function/src/factory.ts index 76536e989b..e3860eb8f3 100644 --- a/packages/backend-function/src/factory.ts +++ b/packages/backend-function/src/factory.ts @@ -13,7 +13,9 @@ import { getCallerDirectory } from './get_caller_directory.js'; /** * Entry point for defining a function in the Amplify ecosystem */ -export const defineFunction = (props: FunctionFactoryProps = {}) => +export const defineFunction = ( + props: FunctionFactoryProps = {} +): ConstructFactory> => new FunctionFactory(props, new Error().stack); export type FunctionFactoryProps = { @@ -39,7 +41,7 @@ export type FunctionFactoryProps = { /** * Create Lambda functions in the context of an Amplify backend definition */ -export class FunctionFactory implements ConstructFactory { +class FunctionFactory implements ConstructFactory { private generator: ConstructContainerEntryGenerator; /** * Create a new AmplifyFunctionFactory From 21f31877b36dd86fb955ac40ccbb0c90752f3cdb Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 16:11:53 -0800 Subject: [PATCH 08/26] fix auto-rename mishap --- packages/backend-function/src/factory.test.ts | 4 ++-- packages/backend-function/src/factory.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend-function/src/factory.test.ts b/packages/backend-function/src/factory.test.ts index 2b9828985a..28809ab46f 100644 --- a/packages/backend-function/src/factory.test.ts +++ b/packages/backend-function/src/factory.test.ts @@ -64,7 +64,7 @@ void describe('AmplifyFunctionFactory', () => { void it('resolves default name when entry specified', () => { const functionFactory = defineFunction({ - entry: './test-assets/default-lambda/handler.js', + entry: './test-assets/default-lambda/handler.ts', }); const lambda = functionFactory.getInstance(getInstanceProps); const template = Template.fromStack(Stack.of(lambda)); @@ -80,7 +80,7 @@ void describe('AmplifyFunctionFactory', () => { void it('uses name and entry that is explicitly specified', () => { const functionFactory = defineFunction({ - entry: './test-assets/default-lambda/handler.js', + entry: './test-assets/default-lambda/handler.ts', name: 'myCoolLambda', }); const lambda = functionFactory.getInstance(getInstanceProps); diff --git a/packages/backend-function/src/factory.ts b/packages/backend-function/src/factory.ts index e3860eb8f3..2f53e5bb67 100644 --- a/packages/backend-function/src/factory.ts +++ b/packages/backend-function/src/factory.ts @@ -85,9 +85,9 @@ class FunctionFactory implements ConstructFactory { }; private resolveEntry = () => { - // if entry is not set, default to handler.js + // if entry is not set, default to handler.ts if (!this.props.entry) { - return path.join(getCallerDirectory(this.callerStack), 'handler.js'); + return path.join(getCallerDirectory(this.callerStack), 'handler.ts'); } // if entry is absolute use that From 886089db68efff8ac4c8494b344d3da488e5b49b Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 27 Nov 2023 16:15:50 -0800 Subject: [PATCH 09/26] update e2e test case --- .../update-1/data/resource.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/data/resource.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/data/resource.ts index 6cf24f1855..ea8523c5f4 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/data/resource.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/data/resource.ts @@ -1,5 +1,10 @@ import { myFunc } from '../function.js'; -import { type ClientSchema, Func, a, defineData } from '@aws-amplify/backend'; +import { + type ClientSchema, + a, + defineData, + defineFunction, +} from '@aws-amplify/backend'; const schema = a.schema({ Todo: a @@ -38,9 +43,9 @@ export const data = defineData({ reverse: myFunc, // Leaving explicit Func invocation here, // ensuring we can use functions not added to `defineBackend`. - echo: Func.fromDir({ + echo: defineFunction({ name: 'echoFunc', - codePath: './echo', + entry: './echo/handler.ts', }), }, }); From 1a5a5dd190aa0680eb7d71d419786e585d233a45 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 28 Nov 2023 09:40:53 -0800 Subject: [PATCH 10/26] add additional check to e2e suite --- package-lock.json | 496 +++++++++++++++++- packages/backend-function/package.json | 3 +- packages/backend-function/src/factory.test.ts | 18 + .../lambda-with-dependencies/handler.ts | 6 + .../lambda-with-dependencies/resource.ts | 3 + .../response_generator.ts | 6 + packages/integration-tests/package.json | 6 +- .../src/find_deployed_resource.ts | 45 ++ .../src/test-e2e/deployment.test.ts | 6 +- .../data_storage_auth_with_triggers.ts | 43 +- .../test-project-setup/test_project_base.ts | 6 +- .../test_project_creator.ts | 8 +- .../amplify/func-src/handler.ts | 9 +- .../amplify/func-src/response_generator.ts | 6 + 14 files changed, 640 insertions(+), 21 deletions(-) create mode 100644 packages/backend-function/src/test-assets/lambda-with-dependencies/handler.ts create mode 100644 packages/backend-function/src/test-assets/lambda-with-dependencies/resource.ts create mode 100644 packages/backend-function/src/test-assets/lambda-with-dependencies/response_generator.ts create mode 100644 packages/integration-tests/src/find_deployed_resource.ts create mode 100644 packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts diff --git a/package-lock.json b/package-lock.json index 72380a712c..424c3a2f25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2903,6 +2903,469 @@ "node": ">=14.0.0" } }, + "node_modules/@aws-sdk/client-lambda": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.460.0.tgz", + "integrity": "sha512-GxLIzgLHSUqWXRbTOoSt7d7GG6RTkAT56yuBNDqT2JZmbYn6vSrpoEAEyVninKHx00vfKgXV2M4aOc1koT2YeQ==", + "dev": true, + "dependencies": { + "@aws-crypto/sha256-browser": "3.0.0", + "@aws-crypto/sha256-js": "3.0.0", + "@aws-sdk/client-sts": "3.460.0", + "@aws-sdk/core": "3.451.0", + "@aws-sdk/credential-provider-node": "3.460.0", + "@aws-sdk/middleware-host-header": "3.460.0", + "@aws-sdk/middleware-logger": "3.460.0", + "@aws-sdk/middleware-recursion-detection": "3.460.0", + "@aws-sdk/middleware-signing": "3.460.0", + "@aws-sdk/middleware-user-agent": "3.460.0", + "@aws-sdk/region-config-resolver": "3.451.0", + "@aws-sdk/types": "3.460.0", + "@aws-sdk/util-endpoints": "3.460.0", + "@aws-sdk/util-user-agent-browser": "3.460.0", + "@aws-sdk/util-user-agent-node": "3.460.0", + "@smithy/config-resolver": "^2.0.18", + "@smithy/eventstream-serde-browser": "^2.0.13", + "@smithy/eventstream-serde-config-resolver": "^2.0.13", + "@smithy/eventstream-serde-node": "^2.0.13", + "@smithy/fetch-http-handler": "^2.2.6", + "@smithy/hash-node": "^2.0.15", + "@smithy/invalid-dependency": "^2.0.13", + "@smithy/middleware-content-length": "^2.0.15", + "@smithy/middleware-endpoint": "^2.2.0", + "@smithy/middleware-retry": "^2.0.20", + "@smithy/middleware-serde": "^2.0.13", + "@smithy/middleware-stack": "^2.0.7", + "@smithy/node-config-provider": "^2.1.5", + "@smithy/node-http-handler": "^2.1.9", + "@smithy/protocol-http": "^3.0.9", + "@smithy/smithy-client": "^2.1.15", + "@smithy/types": "^2.5.0", + "@smithy/url-parser": "^2.0.13", + "@smithy/util-base64": "^2.0.1", + "@smithy/util-body-length-browser": "^2.0.0", + "@smithy/util-body-length-node": "^2.1.0", + "@smithy/util-defaults-mode-browser": "^2.0.19", + "@smithy/util-defaults-mode-node": "^2.0.25", + "@smithy/util-endpoints": "^1.0.4", + "@smithy/util-retry": "^2.0.6", + "@smithy/util-stream": "^2.0.20", + "@smithy/util-utf8": "^2.0.2", + "@smithy/util-waiter": "^2.0.13", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/client-sso": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.460.0.tgz", + "integrity": "sha512-p5D9C8LKJs5yoBn5cCs2Wqzrp5YP5BYcP774bhGMFEu/LCIUyWzudwN3+/AObSiq8R8SSvBY2zQD4h+k3NjgTQ==", + "dev": true, + "dependencies": { + "@aws-crypto/sha256-browser": "3.0.0", + "@aws-crypto/sha256-js": "3.0.0", + "@aws-sdk/core": "3.451.0", + "@aws-sdk/middleware-host-header": "3.460.0", + "@aws-sdk/middleware-logger": "3.460.0", + "@aws-sdk/middleware-recursion-detection": "3.460.0", + "@aws-sdk/middleware-user-agent": "3.460.0", + "@aws-sdk/region-config-resolver": "3.451.0", + "@aws-sdk/types": "3.460.0", + "@aws-sdk/util-endpoints": "3.460.0", + "@aws-sdk/util-user-agent-browser": "3.460.0", + "@aws-sdk/util-user-agent-node": "3.460.0", + "@smithy/config-resolver": "^2.0.18", + "@smithy/fetch-http-handler": "^2.2.6", + "@smithy/hash-node": "^2.0.15", + "@smithy/invalid-dependency": "^2.0.13", + "@smithy/middleware-content-length": "^2.0.15", + "@smithy/middleware-endpoint": "^2.2.0", + "@smithy/middleware-retry": "^2.0.20", + "@smithy/middleware-serde": "^2.0.13", + "@smithy/middleware-stack": "^2.0.7", + "@smithy/node-config-provider": "^2.1.5", + "@smithy/node-http-handler": "^2.1.9", + "@smithy/protocol-http": "^3.0.9", + "@smithy/smithy-client": "^2.1.15", + "@smithy/types": "^2.5.0", + "@smithy/url-parser": "^2.0.13", + "@smithy/util-base64": "^2.0.1", + "@smithy/util-body-length-browser": "^2.0.0", + "@smithy/util-body-length-node": "^2.1.0", + "@smithy/util-defaults-mode-browser": "^2.0.19", + "@smithy/util-defaults-mode-node": "^2.0.25", + "@smithy/util-endpoints": "^1.0.4", + "@smithy/util-retry": "^2.0.6", + "@smithy/util-utf8": "^2.0.2", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/client-sts": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.460.0.tgz", + "integrity": "sha512-Z4h9hZJG5RB9iwhyXlkcnJqCP25+rgIrT8UDryItJfWyK+Pberk1Zft7XwEiyDGXoc48BJvtf7SbOwx3cutgFw==", + "dev": true, + "dependencies": { + "@aws-crypto/sha256-browser": "3.0.0", + "@aws-crypto/sha256-js": "3.0.0", + "@aws-sdk/core": "3.451.0", + "@aws-sdk/credential-provider-node": "3.460.0", + "@aws-sdk/middleware-host-header": "3.460.0", + "@aws-sdk/middleware-logger": "3.460.0", + "@aws-sdk/middleware-recursion-detection": "3.460.0", + "@aws-sdk/middleware-sdk-sts": "3.460.0", + "@aws-sdk/middleware-signing": "3.460.0", + "@aws-sdk/middleware-user-agent": "3.460.0", + "@aws-sdk/region-config-resolver": "3.451.0", + "@aws-sdk/types": "3.460.0", + "@aws-sdk/util-endpoints": "3.460.0", + "@aws-sdk/util-user-agent-browser": "3.460.0", + "@aws-sdk/util-user-agent-node": "3.460.0", + "@smithy/config-resolver": "^2.0.18", + "@smithy/fetch-http-handler": "^2.2.6", + "@smithy/hash-node": "^2.0.15", + "@smithy/invalid-dependency": "^2.0.13", + "@smithy/middleware-content-length": "^2.0.15", + "@smithy/middleware-endpoint": "^2.2.0", + "@smithy/middleware-retry": "^2.0.20", + "@smithy/middleware-serde": "^2.0.13", + "@smithy/middleware-stack": "^2.0.7", + "@smithy/node-config-provider": "^2.1.5", + "@smithy/node-http-handler": "^2.1.9", + "@smithy/protocol-http": "^3.0.9", + "@smithy/smithy-client": "^2.1.15", + "@smithy/types": "^2.5.0", + "@smithy/url-parser": "^2.0.13", + "@smithy/util-base64": "^2.0.1", + "@smithy/util-body-length-browser": "^2.0.0", + "@smithy/util-body-length-node": "^2.1.0", + "@smithy/util-defaults-mode-browser": "^2.0.19", + "@smithy/util-defaults-mode-node": "^2.0.25", + "@smithy/util-endpoints": "^1.0.4", + "@smithy/util-retry": "^2.0.6", + "@smithy/util-utf8": "^2.0.2", + "fast-xml-parser": "4.2.5", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/credential-provider-env": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.460.0.tgz", + "integrity": "sha512-WWdaRJFuYRc2Ue9NKDy2NIf8pQRNx/QRVmrsk6EkIID8uWlQIOePk3SWTVV0TZIyPrbfSEaSnJRZoShphJ6PAg==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/credential-provider-ini": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.460.0.tgz", + "integrity": "sha512-1IEUmyaWzt2M3mONO8QyZtPy0f9ccaEjCo48ZQLgptWxUI+Ohga9gPK0mqu1kTJOjv4JJGACYHzLwEnnpltGlA==", + "dev": true, + "dependencies": { + "@aws-sdk/credential-provider-env": "3.460.0", + "@aws-sdk/credential-provider-process": "3.460.0", + "@aws-sdk/credential-provider-sso": "3.460.0", + "@aws-sdk/credential-provider-web-identity": "3.460.0", + "@aws-sdk/types": "3.460.0", + "@smithy/credential-provider-imds": "^2.0.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/shared-ini-file-loader": "^2.0.6", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/credential-provider-node": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.460.0.tgz", + "integrity": "sha512-PbPo92WIgNlF6V4eWKehYGYjTqf0gU9vr09LeQUc3bTm1DJhJw1j+HU/3PfQ8LwTkBQePO7MbJ5A2n6ckMwfMg==", + "dev": true, + "dependencies": { + "@aws-sdk/credential-provider-env": "3.460.0", + "@aws-sdk/credential-provider-ini": "3.460.0", + "@aws-sdk/credential-provider-process": "3.460.0", + "@aws-sdk/credential-provider-sso": "3.460.0", + "@aws-sdk/credential-provider-web-identity": "3.460.0", + "@aws-sdk/types": "3.460.0", + "@smithy/credential-provider-imds": "^2.0.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/shared-ini-file-loader": "^2.0.6", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/credential-provider-process": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.460.0.tgz", + "integrity": "sha512-ng+0FMc4EaxLAwdttCwf2nzNf4AgcqAHZ8pKXUf8qF/KVkoyTt3UZKW7P2FJI01zxwP+V4yAwVt95PBUKGn4YQ==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/shared-ini-file-loader": "^2.0.6", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/credential-provider-sso": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.460.0.tgz", + "integrity": "sha512-KnrQieOw17+aHEzE3SwfxjeSQ5ZTe2HeAzxkaZF++GxhNul/PkVnLzjGpIuB9bn71T9a2oNfG3peDUA+m2l2kw==", + "dev": true, + "dependencies": { + "@aws-sdk/client-sso": "3.460.0", + "@aws-sdk/token-providers": "3.460.0", + "@aws-sdk/types": "3.460.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/shared-ini-file-loader": "^2.0.6", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/credential-provider-web-identity": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.460.0.tgz", + "integrity": "sha512-7OeaZgC3HmJZGE0I0ZiKInUMF2LyA0IZiW85AYFnAZzAIfv1cXk/1UnDAoFIQhOZfnUBXivStagz892s480ryw==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-host-header": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.460.0.tgz", + "integrity": "sha512-qBeDyuJkEuHe87Xk6unvFO9Zg5j6zM8bQOOZITocTLfu9JN0u5V4GQ/yopvpv+nQHmC/MGr0G7p+kIXMrg/Q2A==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/protocol-http": "^3.0.9", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-logger": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.460.0.tgz", + "integrity": "sha512-w2AJ6HOJ+Ggx9+VDKuWBHk5S0ZxYEo2EY2IFh0qtCQ1RDix/ur1QEzOOL5vNjHlZKPv/dseIwhgsTCac8UHXbQ==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-recursion-detection": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.460.0.tgz", + "integrity": "sha512-wmzm1/2NzpcCVCAsGqqiTBK+xNyLmQwTOq63rcW6eeq6gYOO0cyTZROOkVRrrsKWPBigrSFFHvDrEvonOMtKAg==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/protocol-http": "^3.0.9", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-sdk-sts": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-sts/-/middleware-sdk-sts-3.460.0.tgz", + "integrity": "sha512-eAaKBULwvIEToKweJtZ+gLrDPVwdi/XYjiJMJFBVDFk1n6kfHeS6BlNVrw713YrThpPiWfKNz8U3TvWtvD2Wpg==", + "dev": true, + "dependencies": { + "@aws-sdk/middleware-signing": "3.460.0", + "@aws-sdk/types": "3.460.0", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-signing": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-signing/-/middleware-signing-3.460.0.tgz", + "integrity": "sha512-f7dPf0TdyGMMlMoaGLV85nCfcGZOMIaNm+nR0x21H4SJyn1vCNSLMD6Nksav26hAdI3zreBtI2enudj8YYl2XA==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/property-provider": "^2.0.0", + "@smithy/protocol-http": "^3.0.9", + "@smithy/signature-v4": "^2.0.0", + "@smithy/types": "^2.5.0", + "@smithy/util-middleware": "^2.0.6", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-user-agent": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.460.0.tgz", + "integrity": "sha512-0gBSOCr+RtwRUCSRLn9H3RVnj9ercvk/QKTHIr33CgfEdyZtIGpHWUSs6uqiQydPTRzjCm5SfUa6ESGhRVMM6A==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@aws-sdk/util-endpoints": "3.460.0", + "@smithy/protocol-http": "^3.0.9", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/token-providers": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.460.0.tgz", + "integrity": "sha512-EvSIPMI1gXk3gEkdtbZCW+p3Bjmt2gOR1m7ibQD7qLj4l0dKXhp4URgTqB1ExH3S4qUq0M/XSGKbGLZpvunHNg==", + "dev": true, + "dependencies": { + "@aws-crypto/sha256-browser": "3.0.0", + "@aws-crypto/sha256-js": "3.0.0", + "@aws-sdk/middleware-host-header": "3.460.0", + "@aws-sdk/middleware-logger": "3.460.0", + "@aws-sdk/middleware-recursion-detection": "3.460.0", + "@aws-sdk/middleware-user-agent": "3.460.0", + "@aws-sdk/region-config-resolver": "3.451.0", + "@aws-sdk/types": "3.460.0", + "@aws-sdk/util-endpoints": "3.460.0", + "@aws-sdk/util-user-agent-browser": "3.460.0", + "@aws-sdk/util-user-agent-node": "3.460.0", + "@smithy/config-resolver": "^2.0.18", + "@smithy/fetch-http-handler": "^2.2.6", + "@smithy/hash-node": "^2.0.15", + "@smithy/invalid-dependency": "^2.0.13", + "@smithy/middleware-content-length": "^2.0.15", + "@smithy/middleware-endpoint": "^2.2.0", + "@smithy/middleware-retry": "^2.0.20", + "@smithy/middleware-serde": "^2.0.13", + "@smithy/middleware-stack": "^2.0.7", + "@smithy/node-config-provider": "^2.1.5", + "@smithy/node-http-handler": "^2.1.9", + "@smithy/property-provider": "^2.0.0", + "@smithy/protocol-http": "^3.0.9", + "@smithy/shared-ini-file-loader": "^2.0.6", + "@smithy/smithy-client": "^2.1.15", + "@smithy/types": "^2.5.0", + "@smithy/url-parser": "^2.0.13", + "@smithy/util-base64": "^2.0.1", + "@smithy/util-body-length-browser": "^2.0.0", + "@smithy/util-body-length-node": "^2.1.0", + "@smithy/util-defaults-mode-browser": "^2.0.19", + "@smithy/util-defaults-mode-node": "^2.0.25", + "@smithy/util-endpoints": "^1.0.4", + "@smithy/util-retry": "^2.0.6", + "@smithy/util-utf8": "^2.0.2", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/types": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.460.0.tgz", + "integrity": "sha512-MyZSWS/FV8Bnux5eD9en7KLgVxevlVrGNEP3X2D7fpnUlLhl0a7k8+OpSI2ozEQB8hIU2DLc/XXTKRerHSefxQ==", + "dev": true, + "dependencies": { + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/util-endpoints": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.460.0.tgz", + "integrity": "sha512-myH6kM5WP4IWULHDHMYf2Q+BCYVGlzqJgiBmO10kQEtJSeAGZZ49eoFFYgKW8ZAYB5VnJ+XhXVB1TRA+vR4l5A==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/util-endpoints": "^1.0.4", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/util-user-agent-browser": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.460.0.tgz", + "integrity": "sha512-FRCzW+TyjKnvxsargPVrjayBfp/rvObYHZyZ2OSqrVw8lkkPCb4e/WZOeIiXZuhdhhoah7wMuo6zGwtFF3bYKg==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/types": "^2.5.0", + "bowser": "^2.11.0", + "tslib": "^2.5.0" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/util-user-agent-node": { + "version": "3.460.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.460.0.tgz", + "integrity": "sha512-+kSoR9ABGpJ5Xc7v0VwpgTQbgyI4zuezC8K4pmKAGZsSsVWg4yxptoy2bDqoFL7qfRlWviMVTkQRMvR4D44WxA==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "3.460.0", + "@smithy/node-config-provider": "^2.1.5", + "@smithy/types": "^2.5.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "aws-crt": ">=1.0.0" + }, + "peerDependenciesMeta": { + "aws-crt": { + "optional": true + } + } + }, "node_modules/@aws-sdk/client-s3": { "version": "3.454.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.454.0.tgz", @@ -20096,13 +20559,27 @@ }, "devDependencies": { "@aws-amplify/backend-platform-test-stubs": "^0.3.1", - "@aws-amplify/platform-core": "^0.3.1" + "@aws-amplify/platform-core": "^0.3.1", + "uuid": "^9.0.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", "constructs": "^10.0.0" } }, + "packages/backend-function/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "packages/backend-output-schemas": { "name": "@aws-amplify/backend-output-schemas", "version": "0.4.0", @@ -20542,9 +21019,11 @@ "@aws-amplify/platform-core": "^0.3.1", "@aws-sdk/client-amplify": "^3.440.0", "@aws-sdk/client-cloudformation": "^3.421.0", + "@aws-sdk/client-lambda": "^3.460.0", "execa": "^8.0.1", "fs-extra": "^11.1.1", - "glob": "^10.2.7" + "glob": "^10.2.7", + "uuid": "^9.0.1" } }, "packages/integration-tests/node_modules/execa": { @@ -20599,6 +21078,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "packages/integration-tests/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "packages/model-generator": { "name": "@aws-amplify/model-generator", "version": "0.2.3", diff --git a/packages/backend-function/package.json b/packages/backend-function/package.json index 00db460121..a4c5b576a2 100644 --- a/packages/backend-function/package.json +++ b/packages/backend-function/package.json @@ -24,7 +24,8 @@ }, "devDependencies": { "@aws-amplify/backend-platform-test-stubs": "^0.3.1", - "@aws-amplify/platform-core": "^0.3.1" + "@aws-amplify/platform-core": "^0.3.1", + "uuid": "^9.0.1" }, "peerDependencies": { "aws-cdk-lib": "^2.110.1", diff --git a/packages/backend-function/src/factory.test.ts b/packages/backend-function/src/factory.test.ts index 28809ab46f..bb884d82ba 100644 --- a/packages/backend-function/src/factory.test.ts +++ b/packages/backend-function/src/factory.test.ts @@ -10,6 +10,7 @@ import { import { defaultLambda } from './test-assets/default-lambda/resource.js'; import { Template } from 'aws-cdk-lib/assertions'; import { defineFunction } from './factory.js'; +import { lambdaWithDependencies } from './test-assets/lambda-with-dependencies/resource.js'; const createStackAndSetContext = (): Stack => { const app = new App(); @@ -94,4 +95,21 @@ void describe('AmplifyFunctionFactory', () => { )[0]; assert.ok(lambdaLogicalId.includes('myCoolLambda')); }); + + void it('builds lambda with local and 3p dependencies', () => { + const lambda = lambdaWithDependencies.getInstance(getInstanceProps); + const template = Template.fromStack(Stack.of(lambda)); + // There isn't a way to check the contents of the bundled lambda using the CDK Template utility + // So we just check that the lambda was created properly in the CFN template. + // There is an e2e test that validates proper lambda bundling + template.resourceCountIs('AWS::Lambda::Function', 1); + template.hasResourceProperties('AWS::Lambda::Function', { + Handler: 'index.handler', + }); + const lambdaLogicalId = Object.keys( + template.findResources('AWS::Lambda::Function') + )[0]; + // eslint-disable-next-line spellcheck/spell-checker + assert.ok(lambdaLogicalId.includes('lambdawithdependencies')); + }); }); diff --git a/packages/backend-function/src/test-assets/lambda-with-dependencies/handler.ts b/packages/backend-function/src/test-assets/lambda-with-dependencies/handler.ts new file mode 100644 index 0000000000..5af50164c1 --- /dev/null +++ b/packages/backend-function/src/test-assets/lambda-with-dependencies/handler.ts @@ -0,0 +1,6 @@ +import { getResponse } from './response_generator.js'; + +/** + * Dummy lambda handler to test building a function with a local import + */ +export const handler = async () => getResponse(); diff --git a/packages/backend-function/src/test-assets/lambda-with-dependencies/resource.ts b/packages/backend-function/src/test-assets/lambda-with-dependencies/resource.ts new file mode 100644 index 0000000000..d6a769e02f --- /dev/null +++ b/packages/backend-function/src/test-assets/lambda-with-dependencies/resource.ts @@ -0,0 +1,3 @@ +import { defineFunction } from '../../factory.js'; + +export const lambdaWithDependencies = defineFunction(); diff --git a/packages/backend-function/src/test-assets/lambda-with-dependencies/response_generator.ts b/packages/backend-function/src/test-assets/lambda-with-dependencies/response_generator.ts new file mode 100644 index 0000000000..ff6431ceb6 --- /dev/null +++ b/packages/backend-function/src/test-assets/lambda-with-dependencies/response_generator.ts @@ -0,0 +1,6 @@ +import { v4 as uuid } from 'uuid'; + +/** + * Dummy function to test building a lambda that has a 3p import + */ +export const getResponse = () => `Your uuid is ${uuid()}`; diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index c3523397cc..07cc221c66 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -10,12 +10,14 @@ "@aws-amplify/backend-storage": "0.3.1", "@aws-amplify/client-config": "^0.4.0", "@aws-amplify/data-schema": "^0.12.9", + "@aws-amplify/platform-core": "^0.3.1", "@aws-sdk/client-amplify": "^3.440.0", "@aws-sdk/client-cloudformation": "^3.421.0", - "@aws-amplify/platform-core": "^0.3.1", + "@aws-sdk/client-lambda": "^3.460.0", "execa": "^8.0.1", "fs-extra": "^11.1.1", - "glob": "^10.2.7" + "glob": "^10.2.7", + "uuid": "^9.0.1" }, "scripts": { "update:api": "api-extractor run --local" diff --git a/packages/integration-tests/src/find_deployed_resource.ts b/packages/integration-tests/src/find_deployed_resource.ts new file mode 100644 index 0000000000..cbae55e5ff --- /dev/null +++ b/packages/integration-tests/src/find_deployed_resource.ts @@ -0,0 +1,45 @@ +import { BackendIdentifier } from '@aws-amplify/plugin-types'; +import { + CloudFormationClient, + DescribeStackResourcesCommand, +} from '@aws-sdk/client-cloudformation'; +import { BackendIdentifierConversions } from '@aws-amplify/platform-core'; + +/** + * Returns the physical IDs of the resources of type "resourceType" in the stack defined by "backendId" + * Traverses nested stacks as well + */ +export const findDeployedResources = async ( + cfnClient: CloudFormationClient, + backendId: BackendIdentifier, + resourceType: string +): Promise => { + const stackName = BackendIdentifierConversions.toStackName(backendId); + + const queue = [stackName]; + + const resourcePhysicalIds: string[] = []; + + while (queue.length > 0) { + const currentStack = queue.pop(); + const response = await cfnClient.send( + new DescribeStackResourcesCommand({ StackName: currentStack }) + ); + + for (const resource of response.StackResources || []) { + if ( + resource.ResourceType === 'AWS::CloudFormation::Stack' && + resource.PhysicalResourceId + ) { + queue.unshift(resource.PhysicalResourceId); + } else if ( + resource.ResourceType === resourceType && + resource.PhysicalResourceId + ) { + resourcePhysicalIds.push(resource.PhysicalResourceId!); + } + } + } + + return resourcePhysicalIds; +}; diff --git a/packages/integration-tests/src/test-e2e/deployment.test.ts b/packages/integration-tests/src/test-e2e/deployment.test.ts index 910c7ed9e3..8799a32361 100644 --- a/packages/integration-tests/src/test-e2e/deployment.test.ts +++ b/packages/integration-tests/src/test-e2e/deployment.test.ts @@ -58,7 +58,7 @@ void describe( void it(`[${testProjectCreator.name}] deploys fully`, async () => { await testProject.deploy(branchBackendIdentifier); - await testProject.assertPostDeployment(); + await testProject.assertPostDeployment(branchBackendIdentifier); const testBranchDetails = await amplifyAppPool.fetchTestBranchDetails( testBranch ); @@ -123,7 +123,7 @@ void describe( void describe('in sequence', { concurrency: false }, () => { void it(`[${testProjectCreator.name}] deploys fully`, async () => { await testProject.deploy(sandboxBackendIdentifier); - await testProject.assertPostDeployment(); + await testProject.assertPostDeployment(sandboxBackendIdentifier); }); void it(`[${testProjectCreator.name}] hot-swaps a change`, async () => { @@ -145,7 +145,7 @@ void describe( .do(rejectCleanupSandbox()) .run(); - await testProject.assertPostDeployment(); + await testProject.assertPostDeployment(sandboxBackendIdentifier); }); }); }); diff --git a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts index 9a64df3b29..4baea38a90 100644 --- a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts +++ b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts @@ -7,6 +7,9 @@ import { TestProjectBase, TestProjectUpdate } from './test_project_base.js'; import { fileURLToPath, pathToFileURL } from 'url'; import path from 'path'; import { TestProjectCreator } from './test_project_creator.js'; +import { findDeployedResources } from '../find_deployed_resource.js'; +import assert from 'node:assert'; +import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda'; type TestConstant = { secretNames: { @@ -27,7 +30,8 @@ export class DataStorageAuthWithTriggerTestProjectCreator */ constructor( private readonly cfnClient: CloudFormationClient, - private readonly secretClient: SecretClient + private readonly secretClient: SecretClient, + private readonly lambdaClient: LambdaClient ) {} createProject = async (e2eProjectDir: string): Promise => { @@ -39,7 +43,8 @@ export class DataStorageAuthWithTriggerTestProjectCreator projectRoot, projectAmplifyDir, this.cfnClient, - this.secretClient + this.secretClient, + this.lambdaClient ); await fs.cp( project.sourceProjectAmplifyDirPath, @@ -86,7 +91,8 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { projectDirPath: string, projectAmplifyDirPath: string, cfnClient: CloudFormationClient, - private readonly secretClient: SecretClient + private readonly secretClient: SecretClient, + private readonly lambdaClient: LambdaClient ) { super(name, projectDirPath, projectAmplifyDirPath, cfnClient); } @@ -129,7 +135,34 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { ]; } - setUpDeployEnvironment = async ( + override async assertPostDeployment( + backendId: BackendIdentifier + ): Promise { + await super.assertPostDeployment(backendId); + + // Check that deployed lambda is working correctly + + // find lambda function + const lambdas = await findDeployedResources( + this.cfnClient, + backendId, + 'AWS::Lambda::Function' + ); + + assert.equal(lambdas.length, 1); + const lambdaName = lambdas[0]; + + // invoke the lambda + const response = await this.lambdaClient.send( + new InvokeCommand({ FunctionName: lambdaName }) + ); + const responsePayload = response.Payload?.transformToString(); + + // check expected response + assert.ok(responsePayload && responsePayload.includes('Your uuid is')); + } + + private setUpDeployEnvironment = async ( backendId: BackendIdentifier ): Promise => { const { secretNames } = (await import( @@ -142,7 +175,7 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { } }; - clearDeployEnvironment = async ( + private clearDeployEnvironment = async ( backendId: BackendIdentifier ): Promise => { const { secretNames } = (await import( diff --git a/packages/integration-tests/src/test-project-setup/test_project_base.ts b/packages/integration-tests/src/test-project-setup/test_project_base.ts index d70a845592..f7b6013211 100644 --- a/packages/integration-tests/src/test-project-setup/test_project_base.ts +++ b/packages/integration-tests/src/test-project-setup/test_project_base.ts @@ -41,7 +41,7 @@ export abstract class TestProjectBase { readonly name: string, readonly projectDirPath: string, readonly projectAmplifyDirPath: string, - private readonly cfnClient: CloudFormationClient + protected readonly cfnClient: CloudFormationClient ) {} /** @@ -99,7 +99,9 @@ export abstract class TestProjectBase { /** * Verify the project after deployment. */ - async assertPostDeployment(): Promise { + // suppressing because subclass implementations can use backendId + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async assertPostDeployment(backendId: BackendIdentifier): Promise { await this.assertClientConfigExists( this.projectDirPath, ClientConfigFormat.JSON diff --git a/packages/integration-tests/src/test-project-setup/test_project_creator.ts b/packages/integration-tests/src/test-project-setup/test_project_creator.ts index 088cbf5029..7b9baff83e 100644 --- a/packages/integration-tests/src/test-project-setup/test_project_creator.ts +++ b/packages/integration-tests/src/test-project-setup/test_project_creator.ts @@ -3,6 +3,7 @@ import { CloudFormationClient } from '@aws-sdk/client-cloudformation'; import { getSecretClient } from '@aws-amplify/backend-secret'; import { DataStorageAuthWithTriggerTestProjectCreator } from './data_storage_auth_with_triggers.js'; import { MinimalWithTypescriptIdiomTestProjectCreator } from './minimal_with_typescript_idioms.js'; +import { LambdaClient } from '@aws-sdk/client-lambda'; export type TestProjectCreator = { readonly name: string; @@ -15,9 +16,14 @@ export type TestProjectCreator = { export const getTestProjectCreators = (): TestProjectCreator[] => { const testProjectCreators: TestProjectCreator[] = []; const cfnClient = new CloudFormationClient(); + const lambdaClient = new LambdaClient(); const secretClient = getSecretClient(); testProjectCreators.push( - new DataStorageAuthWithTriggerTestProjectCreator(cfnClient, secretClient), + new DataStorageAuthWithTriggerTestProjectCreator( + cfnClient, + secretClient, + lambdaClient + ), new MinimalWithTypescriptIdiomTestProjectCreator(cfnClient) ); return testProjectCreators; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts index 6a08fdd75d..5af50164c1 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/handler.ts @@ -1,7 +1,6 @@ +import { getResponse } from './response_generator.js'; + /** - * Hello world lambda used for testing + * Dummy lambda handler to test building a function with a local import */ -export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); -}; +export const handler = async () => getResponse(); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts new file mode 100644 index 0000000000..ff6431ceb6 --- /dev/null +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts @@ -0,0 +1,6 @@ +import { v4 as uuid } from 'uuid'; + +/** + * Dummy function to test building a lambda that has a 3p import + */ +export const getResponse = () => `Your uuid is ${uuid()}`; From 83c8b5617d71a63833fb4dddbcc3299281a57b7d Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 28 Nov 2023 09:42:59 -0800 Subject: [PATCH 11/26] lint fixes --- .../src/find_deployed_resource.ts | 2 +- .../amplify/data/echo/handler.cjs | 14 +++++++------- .../amplify/func-src/handler.cjs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/integration-tests/src/find_deployed_resource.ts b/packages/integration-tests/src/find_deployed_resource.ts index cbae55e5ff..a8719454fc 100644 --- a/packages/integration-tests/src/find_deployed_resource.ts +++ b/packages/integration-tests/src/find_deployed_resource.ts @@ -36,7 +36,7 @@ export const findDeployedResources = async ( resource.ResourceType === resourceType && resource.PhysicalResourceId ) { - resourcePhysicalIds.push(resource.PhysicalResourceId!); + resourcePhysicalIds.push(resource.PhysicalResourceId); } } } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs index a4349bc781..6a08fdd75d 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs @@ -1,7 +1,7 @@ -/** - * Hello world lambda used for testing - */ -export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); -}; +/** + * Hello world lambda used for testing + */ +export const handler = async () => { + // eslint-disable-next-line no-console + console.log('hello world lambda'); +}; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs index d03e589d74..6a08fdd75d 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs @@ -2,6 +2,6 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + // eslint-disable-next-line no-console + console.log('hello world lambda'); }; From c28959f81a980878a492c11567cbf0c8e1b89527 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 28 Nov 2023 09:54:53 -0800 Subject: [PATCH 12/26] update snapshots --- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 4 ++-- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 4361c8a007..8ac1d40e0b 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -421,7 +421,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/91205c1519c983710f9e0aab22e73bae8d8372ba5a806b62f9ef8647eb33b14a.json" + "/a182de170a02fa0442f52776b78b62f97120303916c8e2264e21e22d5368c095.json" ] ] } diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 12c816d30f..754b25685c 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703716371 + "Expires": 1703786083 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 25678ec850..96bc3bcb65 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/c84a3ec2c156886a3c1bf56ef2ac113d1b900ddc3d7c79698bb684efd8bef145.json" + "/731aa841d781b76c1f5bab43c9b309af6fbc1ed82537b41fbe1e7e1ec840497b.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 8aa806e5e4..e943e825a9 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701729165 + "Expires": 1701798877 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index a773f463db..177178127c 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -450,7 +450,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/1342fede173b09c6ed9e98f0c7dd50367fd5591d283c908897425da65ce6067e.json" + "/2fcb3dc002e1e6111a71cec64463d43a7032345397118bbe26aacb1ad12c5047.json" ] ] } @@ -536,7 +536,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/00ee6dd686adb50dd5e21768ccb0d91e9dba03c63dc82a8d4d87dcea2ad8123e.json" + "/7ff3124895df7795897a9c9b302edb8abf0430f4fdf4f29e8837c7148824628f.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 69190e4c97..626062eda0 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703716369 + "Expires": 1703786081 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 45f8e4d367..9d071c6f33 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "bc825239cb5be3934835f8041751aad6fb477a5a32260deb5073387df8b8d05b.zip" + "S3Key": "2596d8294526da88c241ad1785afbce4066fcef3b70faf0f77957d7e1625ce24.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 18972070cb..e788d5638d 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -318,7 +318,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/71a55e17a82505995ebb0e05260381c86a3b163df1525f23e731eb7a878fdaf6.json" + "/917062434a1b60fc3c1de7405cfee60a6a7f35346e1c60621a242ebb27c7482b.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 83e26f5f64..ea804e24a7 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -51,7 +51,7 @@ "ApiId" ] }, - "Expires": 1703716370 + "Expires": 1703786082 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 30fc0f7def..d5b44412f5 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/2e55219172eaff222881c076e1086534ebde36cc2661150b5a5d54b692326cd4.json" + "/4ffe68bb8312602a3cb024e24cdab93c9b3ae3cfeee5059feaa7dc939f4cf0e0.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 5631be4d6b..303793e485 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701729170 + "Expires": 1701798882 } }, "amplifyDataGraphQLAPINONEDS684BF699": { From 10b889335838a5f51c03e174d974ae081a6734f5 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 28 Nov 2023 10:38:48 -0800 Subject: [PATCH 13/26] trying this --- .../test-project-setup/data_storage_auth_with_triggers.ts | 2 ++ .../update-1/data/resource.ts | 2 +- .../update-1/data/resource.ts | 2 +- .../data-storage-auth-with-triggers-ts/amplify/function.ts | 1 + .../update-1/function.ts | 7 +++---- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts index 4baea38a90..0a462ba024 100644 --- a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts +++ b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts @@ -149,6 +149,8 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { 'AWS::Lambda::Function' ); + console.log(`got lambdas:\n${JSON.stringify(lambdas)}`); + assert.equal(lambdas.length, 1); const lambdaName = lambdas[0]; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/update-1/data/resource.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/update-1/data/resource.ts index c89ae4cc0e..a6ef53f3a6 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/update-1/data/resource.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/update-1/data/resource.ts @@ -1,4 +1,4 @@ -import { defineData } from '@aws-amplify/backend-graphql'; +import { defineData } from '@aws-amplify/backend'; const schema = ` input AMPLIFY {globalAuthRule: AuthRule = { allow: public }} # FOR TESTING ONLY! diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/update-1/data/resource.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/update-1/data/resource.ts index c89ae4cc0e..a6ef53f3a6 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/update-1/data/resource.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/update-1/data/resource.ts @@ -1,4 +1,4 @@ -import { defineData } from '@aws-amplify/backend-graphql'; +import { defineData } from '@aws-amplify/backend'; const schema = ` input AMPLIFY {globalAuthRule: AuthRule = { allow: public }} # FOR TESTING ONLY! diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts index 6a43bdbc65..dfc2ef586e 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/function.ts @@ -1,5 +1,6 @@ import { defineFunction } from '@aws-amplify/backend'; export const myFunc = defineFunction({ + name: 'specialTestFunction', entry: './func-src/handler.ts', }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/function.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/function.ts index ea270c6747..6a43bdbc65 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/function.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/update-1/function.ts @@ -1,6 +1,5 @@ -import { Func } from '@aws-amplify/backend'; +import { defineFunction } from '@aws-amplify/backend'; -export const myFunc = Func.fromDir({ - name: 'testFunc', - codePath: './func-src', +export const myFunc = defineFunction({ + entry: './func-src/handler.ts', }); From 78167ce04ee16ca3c52a1412207fbbcfb14ac633 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 28 Nov 2023 10:52:23 -0800 Subject: [PATCH 14/26] updating assertion --- .../data_storage_auth_with_triggers.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts index 0a462ba024..969aa9e5b5 100644 --- a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts +++ b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts @@ -149,19 +149,23 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { 'AWS::Lambda::Function' ); - console.log(`got lambdas:\n${JSON.stringify(lambdas)}`); - - assert.equal(lambdas.length, 1); - const lambdaName = lambdas[0]; + const projectLambda = lambdas.find((lambdaName) => + lambdaName.includes('specialTestFunction') + ); // invoke the lambda const response = await this.lambdaClient.send( - new InvokeCommand({ FunctionName: lambdaName }) + new InvokeCommand({ FunctionName: projectLambda }) ); const responsePayload = response.Payload?.transformToString(); // check expected response - assert.ok(responsePayload && responsePayload.includes('Your uuid is')); + assert.ok( + responsePayload && responsePayload.includes('Your uuid is'), + `Expected lambda payload to include "Your uuid is". Actual payload was ${ + responsePayload ?? '[undefined]' + }` + ); } private setUpDeployEnvironment = async ( From 0c9cd67230e8d05a08662ea6ba1114ea95a8c83b Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Tue, 28 Nov 2023 15:25:39 -0800 Subject: [PATCH 15/26] update snapshots --- ...Id-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...branch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...Id-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...branch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...Id-testBranchName-branch-7d6f6c854a.template.json | 10 +++++----- ...branch7d6f6c854aauth473E022C.nested.template.json | 6 +++--- ...branch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...ch7d6f6c854afunctionDE2842E0.nested.template.json | 12 ++++++------ ...Id-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...branch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...Id-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...branch7d6f6c854adataE67321C2.nested.template.json | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 8ac1d40e0b..d8ae5d2e3d 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -421,7 +421,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/a182de170a02fa0442f52776b78b62f97120303916c8e2264e21e22d5368c095.json" + "/884d1cda54b48410716cec8a6c44e02af2335a02027c96774d9f8ee527be33e8.json" ] ] } diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 754b25685c..22e67a6768 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703786083 + "Expires": 1703805897 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 96bc3bcb65..bc8b640613 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/731aa841d781b76c1f5bab43c9b309af6fbc1ed82537b41fbe1e7e1ec840497b.json" + "/093696458aeb76dde80fb45c48a2949c36fae38231917236cae6f6108b2468a5.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index e943e825a9..e60eb295a7 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701798877 + "Expires": 1701818691 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 177178127c..ad0e879363 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -400,10 +400,10 @@ "Type": "AWS::CloudFormation::Stack", "Properties": { "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionspecialTestFunctionlambda0688CD5DArn": { "Fn::GetAtt": [ "function1351588B", - "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" + "Outputs.amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionspecialTestFunctionlambda0688CD5DArn" ] } }, @@ -423,7 +423,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/601efeefc2f118029b329879a8fe6e995a9c76c75e5ee99588f1b68113b5436f.json" + "/9f71e49e8d317f7bf49b5734f898c8697fd3b5210bf862d6e52cfde157b965c4.json" ] ] } @@ -450,7 +450,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/2fcb3dc002e1e6111a71cec64463d43a7032345397118bbe26aacb1ad12c5047.json" + "/894dd1cd70099427c909c719ec6a5fe89f70b6fb400c621657937943e8591145.json" ] ] } @@ -536,7 +536,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/7ff3124895df7795897a9c9b302edb8abf0430f4fdf4f29e8837c7148824628f.json" + "/a73e0a198661aa2517bd54c759dbb138796661eaa8f501aa565d32dfa1519458.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json index 100298eab8..f7628d4cdd 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854aauth473E022C.nested.template.json @@ -316,7 +316,7 @@ "EmailVerificationSubject": "Verify your new account", "LambdaConfig": { "PostConfirmation": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionspecialTestFunctionlambda0688CD5DArn" } }, "Policies": { @@ -362,7 +362,7 @@ "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { - "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn" + "Ref": "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionspecialTestFunctionlambda0688CD5DArn" }, "Principal": "cognito-idp.amazonaws.com", "SourceArn": { @@ -644,7 +644,7 @@ } }, "Parameters": { - "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { + "referencetoamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionNestedStackfunctionNestedStackResource482C479FOutputsamplifytestAppIdtestBranchNamebranch7d6f6c854afunctionspecialTestFunctionlambda0688CD5DArn": { "Type": "String" } }, diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 626062eda0..b9ce7c2bd3 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703786081 + "Expires": 1703805895 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 9d071c6f33..1c9424700e 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -1,6 +1,6 @@ { "Resources": { - "handlerlambdaServiceRole46D7AF61": { + "specialTestFunctionlambdaServiceRole0C3D972B": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -31,7 +31,7 @@ ] } }, - "handlerlambdaE29D1580": { + "specialTestFunctionlambda1BF9BBA4": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { @@ -48,14 +48,14 @@ "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "handlerlambdaServiceRole46D7AF61", + "specialTestFunctionlambdaServiceRole0C3D972B", "Arn" ] }, "Runtime": "nodejs16.x" }, "DependsOn": [ - "handlerlambdaServiceRole46D7AF61" + "specialTestFunctionlambdaServiceRole0C3D972B" ] }, "echoFunclambdaServiceRoleF37965D7": { @@ -118,10 +118,10 @@ } }, "Outputs": { - "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionhandlerlambda640CAA5DArn": { + "amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionspecialTestFunctionlambda0688CD5DArn": { "Value": { "Fn::GetAtt": [ - "handlerlambdaE29D1580", + "specialTestFunctionlambda1BF9BBA4", "Arn" ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index e788d5638d..09e3d51e12 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -318,7 +318,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/917062434a1b60fc3c1de7405cfee60a6a7f35346e1c60621a242ebb27c7482b.json" + "/d0e545b97e06e0d34636992bc440830f0c99333d18dba3eba1400ddba6bfbdde.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index ea804e24a7..75728d1ebd 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -51,7 +51,7 @@ "ApiId" ] }, - "Expires": 1703786082 + "Expires": 1703805896 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index d5b44412f5..48fc927d1e 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/4ffe68bb8312602a3cb024e24cdab93c9b3ae3cfeee5059feaa7dc939f4cf0e0.json" + "/b83218eeea5a8f4666b0e000e41f0af31c38b6bf05841c3bad3db9f66612aab6.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 303793e485..b88da2fcc2 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701798882 + "Expires": 1701818697 } }, "amplifyDataGraphQLAPINONEDS684BF699": { From 7144d166fe35fc6d0c7aa4439eaa9e8ba8a2b25f Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 08:51:39 -0800 Subject: [PATCH 16/26] addressing PR comments --- packages/backend-function/src/factory.ts | 10 ++-- .../src/test-assets/default-lambda/handler.ts | 3 +- .../src/find_deployed_resource.ts | 55 +++++++++++++++++++ .../data_storage_auth_with_triggers.ts | 32 +++++------ .../test_project_creator.ts | 5 +- .../amplify/data/echo/handler.cjs | 3 +- .../amplify/func-src/handler.cjs | 3 +- .../amplify/data/echo/handler.js | 3 +- .../amplify/func-src/handler.js | 3 +- .../amplify/data/echo/handler.ts | 3 +- .../amplify/func-src/response_generator.ts | 13 ++++- .../amplify/data/lambda_authorizer.ts | 3 +- 12 files changed, 97 insertions(+), 39 deletions(-) diff --git a/packages/backend-function/src/factory.ts b/packages/backend-function/src/factory.ts index 2f53e5bb67..c691cef309 100644 --- a/packages/backend-function/src/factory.ts +++ b/packages/backend-function/src/factory.ts @@ -14,11 +14,11 @@ import { getCallerDirectory } from './get_caller_directory.js'; * Entry point for defining a function in the Amplify ecosystem */ export const defineFunction = ( - props: FunctionFactoryProps = {} + props: FunctionProps = {} ): ConstructFactory> => new FunctionFactory(props, new Error().stack); -export type FunctionFactoryProps = { +export type FunctionProps = { /** * A name for the function. * Defaults to the basename of the entry path if specified. @@ -33,7 +33,7 @@ export type FunctionFactoryProps = { * The path to the file that contains the function entry point. * If this is a relative path, it is computed relative to the file where this function is defined * - * Defaults to './handler.js' + * Defaults to './handler.ts' */ entry?: string; }; @@ -47,7 +47,7 @@ class FunctionFactory implements ConstructFactory { * Create a new AmplifyFunctionFactory */ constructor( - private readonly props: FunctionFactoryProps, + private readonly props: FunctionProps, private readonly callerStack?: string ) {} @@ -100,7 +100,7 @@ class FunctionFactory implements ConstructFactory { }; } -type HydratedFunctionProps = Required; +type HydratedFunctionProps = Required; class FunctionGenerator implements ConstructContainerEntryGenerator { readonly resourceGroupName = 'function'; diff --git a/packages/backend-function/src/test-assets/default-lambda/handler.ts b/packages/backend-function/src/test-assets/default-lambda/handler.ts index f0176ba4b3..b980c66e83 100644 --- a/packages/backend-function/src/test-assets/default-lambda/handler.ts +++ b/packages/backend-function/src/test-assets/default-lambda/handler.ts @@ -2,6 +2,5 @@ * Hello world lambda used for testing defaults to `defineFunction` */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; diff --git a/packages/integration-tests/src/find_deployed_resource.ts b/packages/integration-tests/src/find_deployed_resource.ts index a8719454fc..4e5b31e90a 100644 --- a/packages/integration-tests/src/find_deployed_resource.ts +++ b/packages/integration-tests/src/find_deployed_resource.ts @@ -5,6 +5,61 @@ import { } from '@aws-sdk/client-cloudformation'; import { BackendIdentifierConversions } from '@aws-amplify/platform-core'; +export type StringPredicate = (str: string) => boolean; + +/** + * Class that finds resource physical ids in a deployed stack + */ +export class DeployedResourcesFinder { + /** + * Construct with a cfnClient + */ + constructor(private readonly cfnClient: CloudFormationClient) {} + + /** + * Find resources of type "resourceType" within the stack defined by "backendId" + * Optionally, filter physical names by a predicate + * @param backendId Used to determine which CFN stack to look in + * @param resourceType The CFN resource type to look for. Eg "AWS::Lambda::Function" or "AWS::IAM::Role" + * @param physicalNamePredicate Optional predicate to filter physical names of resources matching resourceType + */ + find = async ( + backendId: BackendIdentifier, + resourceType: string, + physicalNamePredicate: StringPredicate = () => true // match all resources of "resourceType" by default + ): Promise => { + const stackName = BackendIdentifierConversions.toStackName(backendId); + + const queue = [stackName]; + + const resourcePhysicalIds: string[] = []; + + while (queue.length > 0) { + const currentStack = queue.pop(); + const response = await this.cfnClient.send( + new DescribeStackResourcesCommand({ StackName: currentStack }) + ); + + for (const resource of response.StackResources || []) { + if ( + resource.ResourceType === 'AWS::CloudFormation::Stack' && + resource.PhysicalResourceId + ) { + queue.unshift(resource.PhysicalResourceId); + } else if ( + resource.ResourceType === resourceType && + resource.PhysicalResourceId && + physicalNamePredicate(resource.PhysicalResourceId) + ) { + resourcePhysicalIds.push(resource.PhysicalResourceId); + } + } + } + + return resourcePhysicalIds; + }; +} + /** * Returns the physical IDs of the resources of type "resourceType" in the stack defined by "backendId" * Traverses nested stacks as well diff --git a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts index 969aa9e5b5..61fb522c0a 100644 --- a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts +++ b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts @@ -7,7 +7,7 @@ import { TestProjectBase, TestProjectUpdate } from './test_project_base.js'; import { fileURLToPath, pathToFileURL } from 'url'; import path from 'path'; import { TestProjectCreator } from './test_project_creator.js'; -import { findDeployedResources } from '../find_deployed_resource.js'; +import { DeployedResourcesFinder } from '../find_deployed_resource.js'; import assert from 'node:assert'; import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda'; @@ -31,7 +31,8 @@ export class DataStorageAuthWithTriggerTestProjectCreator constructor( private readonly cfnClient: CloudFormationClient, private readonly secretClient: SecretClient, - private readonly lambdaClient: LambdaClient + private readonly lambdaClient: LambdaClient, + private readonly resourceFinder: DeployedResourcesFinder ) {} createProject = async (e2eProjectDir: string): Promise => { @@ -44,7 +45,8 @@ export class DataStorageAuthWithTriggerTestProjectCreator projectAmplifyDir, this.cfnClient, this.secretClient, - this.lambdaClient + this.lambdaClient, + this.resourceFinder ); await fs.cp( project.sourceProjectAmplifyDirPath, @@ -92,7 +94,8 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { projectAmplifyDirPath: string, cfnClient: CloudFormationClient, private readonly secretClient: SecretClient, - private readonly lambdaClient: LambdaClient + private readonly lambdaClient: LambdaClient, + private readonly resourceFinder: DeployedResourcesFinder ) { super(name, projectDirPath, projectAmplifyDirPath, cfnClient); } @@ -143,28 +146,25 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { // Check that deployed lambda is working correctly // find lambda function - const lambdas = await findDeployedResources( - this.cfnClient, + const lambdas = await this.resourceFinder.find( backendId, - 'AWS::Lambda::Function' + 'AWS::Lambda::Function', + (name) => name.includes('specialTestFunction') ); - const projectLambda = lambdas.find((lambdaName) => - lambdaName.includes('specialTestFunction') - ); + assert.equal(lambdas.length, 1); // invoke the lambda const response = await this.lambdaClient.send( - new InvokeCommand({ FunctionName: projectLambda }) + new InvokeCommand({ FunctionName: lambdas[0] }) ); const responsePayload = response.Payload?.transformToString(); // check expected response - assert.ok( - responsePayload && responsePayload.includes('Your uuid is'), - `Expected lambda payload to include "Your uuid is". Actual payload was ${ - responsePayload ?? '[undefined]' - }` + assert.equal( + responsePayload, + // eslint-disable-next-line spellcheck/spell-checker + 'Your uuid is 6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' ); } diff --git a/packages/integration-tests/src/test-project-setup/test_project_creator.ts b/packages/integration-tests/src/test-project-setup/test_project_creator.ts index 7b9baff83e..feba93ec0f 100644 --- a/packages/integration-tests/src/test-project-setup/test_project_creator.ts +++ b/packages/integration-tests/src/test-project-setup/test_project_creator.ts @@ -4,6 +4,7 @@ import { getSecretClient } from '@aws-amplify/backend-secret'; import { DataStorageAuthWithTriggerTestProjectCreator } from './data_storage_auth_with_triggers.js'; import { MinimalWithTypescriptIdiomTestProjectCreator } from './minimal_with_typescript_idioms.js'; import { LambdaClient } from '@aws-sdk/client-lambda'; +import { DeployedResourcesFinder } from '../find_deployed_resource.js'; export type TestProjectCreator = { readonly name: string; @@ -17,12 +18,14 @@ export const getTestProjectCreators = (): TestProjectCreator[] => { const testProjectCreators: TestProjectCreator[] = []; const cfnClient = new CloudFormationClient(); const lambdaClient = new LambdaClient(); + const resourceFinder = new DeployedResourcesFinder(cfnClient); const secretClient = getSecretClient(); testProjectCreators.push( new DataStorageAuthWithTriggerTestProjectCreator( cfnClient, secretClient, - lambdaClient + lambdaClient, + resourceFinder ), new MinimalWithTypescriptIdiomTestProjectCreator(cfnClient) ); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs index 6a08fdd75d..a74409aa20 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/data/echo/handler.cjs @@ -2,6 +2,5 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs index 6a08fdd75d..a74409aa20 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/amplify/func-src/handler.cjs @@ -2,6 +2,5 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.js index 6a08fdd75d..a74409aa20 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.js +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/data/echo/handler.js @@ -2,6 +2,5 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js index 6a08fdd75d..a74409aa20 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/amplify/func-src/handler.js @@ -2,6 +2,5 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts index 6a08fdd75d..a74409aa20 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/data/echo/handler.ts @@ -2,6 +2,5 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts index ff6431ceb6..1fe96b314d 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts @@ -1,6 +1,13 @@ -import { v4 as uuid } from 'uuid'; +import { stringify as uuidStringify } from 'uuid'; /** - * Dummy function to test building a lambda that has a 3p import + * Dummy function to test building a lambda that has a 3P import */ -export const getResponse = () => `Your uuid is ${uuid()}`; +export const getResponse = () => { + // create a deterministic uuid + const uuidBytes = [ + 0x6e, 0xc0, 0xbd, 0x7f, 0x11, 0xc0, 0x43, 0xda, 0x97, 0x5e, 0x2a, 0x8a, + 0xd9, 0xeb, 0xae, 0x0b, + ]; + uuidStringify(uuidBytes); // '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' +}; diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts index 6a08fdd75d..a74409aa20 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/amplify/data/lambda_authorizer.ts @@ -2,6 +2,5 @@ * Hello world lambda used for testing */ export const handler = async () => { - // eslint-disable-next-line no-console - console.log('hello world lambda'); + return 'hello world lambda'; }; From ddea87f9597dc170bd0f86f1839780945c20fcd4 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 08:52:51 -0800 Subject: [PATCH 17/26] update snapshots --- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 4 ++-- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 4 ++-- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 4 ++-- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 4 ++-- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 4 ++-- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- 16 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index d8ae5d2e3d..34c51368bb 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -421,7 +421,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/884d1cda54b48410716cec8a6c44e02af2335a02027c96774d9f8ee527be33e8.json" + "/9178a31371eac6721402c71d63e8f9c74d802e7ffd9df2d02158ffbfed8d5f84.json" ] ] } diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 22e67a6768..66faa430ce 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703805897 + "Expires": 1703868762 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index bc8b640613..7296dbbd5c 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/093696458aeb76dde80fb45c48a2949c36fae38231917236cae6f6108b2468a5.json" + "/92960380a9d41e4a1c2987b119723001fb29c4505577aad383d96ceed06d212b.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index e60eb295a7..4b473d82bd 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701818691 + "Expires": 1701881555 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index bfcd9a76d3..9def60df8d 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -441,7 +441,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/5d08f8b126a912ddd1beed848e702e982ec4e47ec61b9b16587e3f69a05a178f.json" + "/0fbde414ebb3daeaffe0b031f48a97af5b1b5a8e4a7c66e884bbed5962311d38.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 48c3013a26..acfde71c9e 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-cjs/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "d089e71db3f5da301e806bb05088811eb3edc37a581c5ba6d5d0724ec2312d2d.zip" + "S3Key": "6affc7e3567ce94c11b3c71fb1bc09a11e1804ba57a291c7eab4b9c9d4b82e80.zip" }, "Environment": { "Variables": { @@ -96,7 +96,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "e03749374a96d64aa843a04ee69955bfea3fb2446ca547a3609866ba406145fa.zip" + "S3Key": "3432360d5f85e129a10ef49dc990538a80a6347de86143eb4e1cce2529f7145a.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 06b72df5b2..d785da1235 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -441,7 +441,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/b0b7029888764861a5d4be394bc4b5fc7e7973ce21e25adf025d0a9b4c63985a.json" + "/88b7b9e3302285f902b495ec40076afd46e24597fd162e22388db86e33f56c22.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 96efd91474..029b8d1a5e 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-js/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "16d90594449c1ff1bf24d95ed8f9b9c32dc0c9ae124fc88282b693281484614e.zip" + "S3Key": "ce20b1bbd042ee1db4251e55e10f01aad7d6d5d39a0303451585952ce49958db.zip" }, "Environment": { "Variables": { @@ -96,7 +96,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "f6288cec07233727491613f608871e0691909e78729aa27cea27f728303f9190.zip" + "S3Key": "fee8578fcf3b0063089a4abe381e26050b959e96c277ed3b554fd6515fa84151.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index ad0e879363..2f67f62bd3 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -450,7 +450,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/894dd1cd70099427c909c719ec6a5fe89f70b6fb400c621657937943e8591145.json" + "/0beaea1ab519417f2f991451544f2e142fc5291ff849d482986cb3c5fc4ee77c.json" ] ] } @@ -536,7 +536,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/a73e0a198661aa2517bd54c759dbb138796661eaa8f501aa565d32dfa1519458.json" + "/0ac9eae93503d2590d14e738d4a6023639fb0a5635741d1cc91065d3c2dd9ccc.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index b9ce7c2bd3..6597ef24b9 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703805895 + "Expires": 1703868760 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 1c9424700e..9461cdcdd0 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "2596d8294526da88c241ad1785afbce4066fcef3b70faf0f77957d7e1625ce24.zip" + "S3Key": "06205466f6312cccd189d9961998f82179fd465c1fa5f00144c4d85180192862.zip" }, "Environment": { "Variables": { @@ -96,7 +96,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "2d509b0ca61ebd56ec06852b7ebfc7e84217917bb5b62bba1d625938f9b1ec53.zip" + "S3Key": "8ec7c45f429a0cbe47336d1e8f7cd0efae9cd53d7597f14aa180fa922b5be180.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 09e3d51e12..5bb6a484a3 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -318,7 +318,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/d0e545b97e06e0d34636992bc440830f0c99333d18dba3eba1400ddba6bfbdde.json" + "/51045fcf7bdba47ed20c63e671d80f3b24bbf76d42b86e4c1deae706f20888ef.json" ] ] } @@ -345,7 +345,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/f0959cfa9ae54417a52a7f48a64f7f9b3fa5071d067365cd7e99004a2ff8344a.json" + "/36a67e80be9b6f698e1b433195eb1b7a8214ca85775562e0f9bffdf3f1b0b358.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 75728d1ebd..787d262332 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -51,7 +51,7 @@ "ApiId" ] }, - "Expires": 1703805896 + "Expires": 1703868761 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 3dfa775cf8..44d95bec23 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "47989b53bbcbba7ae3b7e09009d89dd2051eb334b2ff3ae9c3ad6eb98af704da.zip" + "S3Key": "4a66b7e5d6972e7f007f7b05bc1120abeebb6878a29ee6071a79eac87896494d.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 48fc927d1e..4ecbf6e831 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/b83218eeea5a8f4666b0e000e41f0af31c38b6bf05841c3bad3db9f66612aab6.json" + "/4e517c3b70060bdb79eb1948bdb853212957bfda91a017833bce981809ffac83.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index b88da2fcc2..76540848ab 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701818697 + "Expires": 1701881561 } }, "amplifyDataGraphQLAPINONEDS684BF699": { From 1ad585d08714b828fb9c73d8e96dd8200269afc7 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 08:54:30 -0800 Subject: [PATCH 18/26] update api extract --- packages/backend-function/API.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend-function/API.md b/packages/backend-function/API.md index 052bc29269..fb15232219 100644 --- a/packages/backend-function/API.md +++ b/packages/backend-function/API.md @@ -10,10 +10,10 @@ import { FunctionResources } from '@aws-amplify/plugin-types'; import { ResourceProvider } from '@aws-amplify/plugin-types'; // @public -export const defineFunction: (props?: FunctionFactoryProps) => ConstructFactory>; +export const defineFunction: (props?: FunctionProps) => ConstructFactory>; // @public (undocumented) -export type FunctionFactoryProps = { +export type FunctionProps = { name?: string; entry?: string; }; From 40f75ad2790afcb6d4d0965aad5ec0336cbb403c Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 08:56:36 -0800 Subject: [PATCH 19/26] update changeset --- .changeset/mighty-rockets-shake.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/mighty-rockets-shake.md b/.changeset/mighty-rockets-shake.md index d2cda1585e..09bfce3e82 100644 --- a/.changeset/mighty-rockets-shake.md +++ b/.changeset/mighty-rockets-shake.md @@ -1,7 +1,7 @@ --- 'create-amplify': patch -'@aws-amplify/plugin-types': patch -'@aws-amplify/backend': patch +'@aws-amplify/plugin-types': minor +'@aws-amplify/backend': minor --- Expose new `defineFunction` interface From edb5ee37a2c0603e9f42a49fed301eba0eb37b2b Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 09:03:30 -0800 Subject: [PATCH 20/26] fix lint --- .../amplify/func-src/response_generator.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts index 1fe96b314d..4bd7b5a28c 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts @@ -9,5 +9,6 @@ export const getResponse = () => { 0x6e, 0xc0, 0xbd, 0x7f, 0x11, 0xc0, 0x43, 0xda, 0x97, 0x5e, 0x2a, 0x8a, 0xd9, 0xeb, 0xae, 0x0b, ]; + // eslint-disable-next-line spellcheck/spell-checker uuidStringify(uuidBytes); // '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' }; From 006f6c39ddd2901504011bf44763e4024930520f Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 09:26:23 -0800 Subject: [PATCH 21/26] Im dumb --- .../amplify/func-src/response_generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts index 4bd7b5a28c..41855b054c 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts @@ -10,5 +10,5 @@ export const getResponse = () => { 0xd9, 0xeb, 0xae, 0x0b, ]; // eslint-disable-next-line spellcheck/spell-checker - uuidStringify(uuidBytes); // '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' + return uuidStringify(uuidBytes); // '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' }; From 6dabee628b373be888dd18a4a5ac45131a09b423 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 09:34:01 -0800 Subject: [PATCH 22/26] still dumb --- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 4 ++-- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 34c51368bb..cf00d082e0 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -421,7 +421,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/9178a31371eac6721402c71d63e8f9c74d802e7ffd9df2d02158ffbfed8d5f84.json" + "/ccd92b769e1530969458a6cbf52382e3efe3fac23bc188f09a13f4a6f2ce5537.json" ] ] } diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 66faa430ce..15b168a52f 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703868762 + "Expires": 1703871235 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 7296dbbd5c..d863508e39 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/92960380a9d41e4a1c2987b119723001fb29c4505577aad383d96ceed06d212b.json" + "/012de50a0e1cb5102793787c50ecec255ee58691afb5b11ad382cff3ff778298.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 4b473d82bd..6fb090a0e2 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701881555 + "Expires": 1701884028 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 2f67f62bd3..0c2f83733e 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -450,7 +450,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/0beaea1ab519417f2f991451544f2e142fc5291ff849d482986cb3c5fc4ee77c.json" + "/897ce835d63df12c3b81c47d1d754010af97f4a75a2ebec746ad86dc2abe47a0.json" ] ] } @@ -536,7 +536,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/0ac9eae93503d2590d14e738d4a6023639fb0a5635741d1cc91065d3c2dd9ccc.json" + "/5762433a95dd3938b747404e465605fd2d67e3e53bd9f453a00f891fdd03b69a.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 6597ef24b9..cc0f93cc7a 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703868760 + "Expires": 1703871233 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index 9461cdcdd0..fec299a6a6 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "06205466f6312cccd189d9961998f82179fd465c1fa5f00144c4d85180192862.zip" + "S3Key": "afa28dd411504f6dd1d9ac52efc6d60b65f777e2132a6d58aca9c741c99060fe.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 5bb6a484a3..ebe1b5a457 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -318,7 +318,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/51045fcf7bdba47ed20c63e671d80f3b24bbf76d42b86e4c1deae706f20888ef.json" + "/bbbfa3573a9e11b356c74c618b8205b6fa2e3279fc734932126adb51bf5ae5a8.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 787d262332..08cbbbafc1 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -51,7 +51,7 @@ "ApiId" ] }, - "Expires": 1703868761 + "Expires": 1703871234 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 4ecbf6e831..fb99fd2f9e 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/4e517c3b70060bdb79eb1948bdb853212957bfda91a017833bce981809ffac83.json" + "/294fbce77edfd9ecbf5511c67eee72f06f622008c4679bf9b249de3a28ac4e16.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 76540848ab..916bebd73a 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701881561 + "Expires": 1701884034 } }, "amplifyDataGraphQLAPINONEDS684BF699": { From 159d3a144aef9f8d626ac97519d4e4786e5992ff Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 09:43:06 -0800 Subject: [PATCH 23/26] remove unused code --- .../src/find_deployed_resource.ts | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/packages/integration-tests/src/find_deployed_resource.ts b/packages/integration-tests/src/find_deployed_resource.ts index 4e5b31e90a..ee52620b06 100644 --- a/packages/integration-tests/src/find_deployed_resource.ts +++ b/packages/integration-tests/src/find_deployed_resource.ts @@ -59,42 +59,3 @@ export class DeployedResourcesFinder { return resourcePhysicalIds; }; } - -/** - * Returns the physical IDs of the resources of type "resourceType" in the stack defined by "backendId" - * Traverses nested stacks as well - */ -export const findDeployedResources = async ( - cfnClient: CloudFormationClient, - backendId: BackendIdentifier, - resourceType: string -): Promise => { - const stackName = BackendIdentifierConversions.toStackName(backendId); - - const queue = [stackName]; - - const resourcePhysicalIds: string[] = []; - - while (queue.length > 0) { - const currentStack = queue.pop(); - const response = await cfnClient.send( - new DescribeStackResourcesCommand({ StackName: currentStack }) - ); - - for (const resource of response.StackResources || []) { - if ( - resource.ResourceType === 'AWS::CloudFormation::Stack' && - resource.PhysicalResourceId - ) { - queue.unshift(resource.PhysicalResourceId); - } else if ( - resource.ResourceType === resourceType && - resource.PhysicalResourceId - ) { - resourcePhysicalIds.push(resource.PhysicalResourceId); - } - } - } - - return resourcePhysicalIds; -}; From 9dfb69ff18b7e67ff81d0034f1c23b3abb4f1097 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 10:16:12 -0800 Subject: [PATCH 24/26] hopefully last fix --- .../amplify/func-src/response_generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts index 41855b054c..d4aa7c8816 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/amplify/func-src/response_generator.ts @@ -10,5 +10,5 @@ export const getResponse = () => { 0xd9, 0xeb, 0xae, 0x0b, ]; // eslint-disable-next-line spellcheck/spell-checker - return uuidStringify(uuidBytes); // '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' + return `Your uuid is ${uuidStringify(uuidBytes)}`; // '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' }; From 257ce66a30b4364f985d9dcb740fba08ef4ec6fd Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 10:24:53 -0800 Subject: [PATCH 25/26] update snapshots --- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 4 ++-- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...hNamebranch7d6f6c854afunctionDE2842E0.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- ...y-testAppId-testBranchName-branch-7d6f6c854a.template.json | 2 +- ...ranchNamebranch7d6f6c854adataE67321C2.nested.template.json | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index cf00d082e0..330c2044fb 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -421,7 +421,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/ccd92b769e1530969458a6cbf52382e3efe3fac23bc188f09a13f4a6f2ce5537.json" + "/7e4162b01ae73ce4493a3faf018e74e8dcfdb2e2b492d56fd7fa86a4d0216b9e.json" ] ] } diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 15b168a52f..42505da381 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703871235 + "Expires": 1703874287 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index d863508e39..74a7676313 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/012de50a0e1cb5102793787c50ecec255ee58691afb5b11ad382cff3ff778298.json" + "/bfd3e79279e8eacf3c19316bcf27a272dae370c6b509102aaaad2e4961c1a27d.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 6fb090a0e2..8fc826d322 100644 --- a/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-iterative-deploy/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701884028 + "Expires": 1701887080 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index 0c2f83733e..45ad8eb373 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -450,7 +450,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/897ce835d63df12c3b81c47d1d754010af97f4a75a2ebec746ad86dc2abe47a0.json" + "/9c68b83eec1055821272eb84581a1d4ed9f5c18f5618be403beca9c6a445f1b1.json" ] ] } @@ -536,7 +536,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/5762433a95dd3938b747404e465605fd2d67e3e53bd9f453a00f891fdd03b69a.json" + "/e963831368bd0f7e3b2b0082e7b252b26aabd105540e7b72eefed8ae755a74a3.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index cc0f93cc7a..3cd991bbec 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -47,7 +47,7 @@ "ApiId" ] }, - "Expires": 1703871233 + "Expires": 1703874285 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json index fec299a6a6..0677184e6c 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers-ts/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854afunctionDE2842E0.nested.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "afa28dd411504f6dd1d9ac52efc6d60b65f777e2132a6d58aca9c741c99060fe.zip" + "S3Key": "d734d72b26bbfcea4362172e7e5076e26ab1859f5e1dffaee893424e20dcb690.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index ebe1b5a457..327f5a3da0 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -318,7 +318,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/bbbfa3573a9e11b356c74c618b8205b6fa2e3279fc734932126adb51bf5ae5a8.json" + "/e12e50ae6dac63924629bba3b6a3d91841ed2a80d653f9332c52adea0f68d1b3.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 08cbbbafc1..279cf94075 100644 --- a/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-auth-modes/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -51,7 +51,7 @@ "ApiId" ] }, - "Expires": 1703871234 + "Expires": 1703874286 } }, "amplifyDataGraphQLAPINONEDS684BF699": { diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json index fb99fd2f9e..8c90c91dc4 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplify-testAppId-testBranchName-branch-7d6f6c854a.template.json @@ -306,7 +306,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/294fbce77edfd9ecbf5511c67eee72f06f622008c4679bf9b249de3a28ac4e16.json" + "/dab1b9c032bac59aec4e3d1ef9c6d8f6c521dfe5c83c3d72465b033bd845d3e6.json" ] ] } diff --git a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json index 916bebd73a..cf5c826eec 100644 --- a/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json +++ b/packages/integration-tests/test-projects/standalone-data-sandbox-mode/expected-cdk-out/amplifytestAppIdtestBranchNamebranch7d6f6c854adataE67321C2.nested.template.json @@ -31,7 +31,7 @@ "ApiId" ] }, - "Expires": 1701884034 + "Expires": 1701887086 } }, "amplifyDataGraphQLAPINONEDS684BF699": { From 8453633bfcdf892c24837667ad5f26838357d8b7 Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Wed, 29 Nov 2023 10:54:17 -0800 Subject: [PATCH 26/26] json parse lambda output --- .../src/test-project-setup/data_storage_auth_with_triggers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts index 61fb522c0a..b5d19abe61 100644 --- a/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts +++ b/packages/integration-tests/src/test-project-setup/data_storage_auth_with_triggers.ts @@ -158,7 +158,9 @@ class DataStorageAuthWithTriggerTestProject extends TestProjectBase { const response = await this.lambdaClient.send( new InvokeCommand({ FunctionName: lambdas[0] }) ); - const responsePayload = response.Payload?.transformToString(); + const responsePayload = JSON.parse( + response.Payload?.transformToString() || '' + ); // check expected response assert.equal(