-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: custom runtimes to define function (#1602)
* feature(function): add custom provided function support to defineFunction * chore: add changeset * chore(function): fix e2ee path and changeset * chore(function): add new API.md * fix(function): fix e2ee tests for provided function Co-authored-by: Kamil Sobol <[email protected]> * chore: change changeset Co-authored-by: Kamil Sobol <[email protected]> * chore(function): add without docker error message Co-authored-by: Kamil Sobol <[email protected]> * chore(function): add provided function error message Co-authored-by: Kamil Sobol <[email protected]> * chore(function): add missing imports * chore(function): fix lint error * Update packages/backend-function/src/provided_function_factory.ts Co-authored-by: Amplifiyer <[email protected]> * Update packages/backend-function/src/provided_function_factory.ts Co-authored-by: Amplifiyer <[email protected]> * chore(function): fix lint issue --------- Co-authored-by: Kamil Sobol <[email protected]> Co-authored-by: Amplifiyer <[email protected]>
- Loading branch information
1 parent
a04dbb8
commit 3f521c3
Showing
11 changed files
with
365 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@aws-amplify/backend-function': minor | ||
'@aws-amplify/backend': minor | ||
--- | ||
|
||
add custom provided function support to define function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Construct } from 'constructs'; | ||
import { | ||
BackendOutputStorageStrategy, | ||
FunctionResources, | ||
ResourceAccessAcceptor, | ||
ResourceAccessAcceptorFactory, | ||
ResourceProvider, | ||
} from '@aws-amplify/plugin-types'; | ||
import { Stack } from 'aws-cdk-lib'; | ||
import { | ||
FunctionOutput, | ||
functionOutputKey, | ||
} from '@aws-amplify/backend-output-schemas'; | ||
import { AttributionMetadataStorage } from '@aws-amplify/backend-output-storage'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const functionStackType = 'function-Lambda'; | ||
|
||
/** | ||
* A base class for function constructs. | ||
*/ | ||
export abstract class AmplifyFunctionBase | ||
extends Construct | ||
implements ResourceProvider<FunctionResources>, ResourceAccessAcceptorFactory | ||
{ | ||
readonly stack: Stack; | ||
abstract resources: FunctionResources; | ||
|
||
abstract getResourceAccessAcceptor: () => ResourceAccessAcceptor; | ||
|
||
/** | ||
* Creates base function construct. | ||
*/ | ||
protected constructor( | ||
scope: Construct, | ||
id: string, | ||
private readonly outputStorageStrategy: BackendOutputStorageStrategy<FunctionOutput> | ||
) { | ||
super(scope, id); | ||
|
||
this.stack = Stack.of(scope); | ||
|
||
new AttributionMetadataStorage().storeAttributionMetadata( | ||
Stack.of(this), | ||
functionStackType, | ||
fileURLToPath(new URL('../package.json', import.meta.url)) | ||
); | ||
} | ||
|
||
protected storeOutput = (): void => { | ||
this.outputStorageStrategy.appendToBackendOutputList(functionOutputKey, { | ||
version: '1', | ||
payload: { | ||
definedFunctions: this.resources.lambda.functionName, | ||
}, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './factory.js'; | ||
import { ProvidedFunctionProps } from './provided_function_factory.js'; | ||
export { ProvidedFunctionProps }; |
Oops, something went wrong.