-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: implemented workaround for aws/aws-cdk#1972
- Loading branch information
Showing
7 changed files
with
62 additions
and
21 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
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,2 @@ | ||
// SSM Parameter Names: Lambda Layer Arns | ||
export const NPM_DEPENDENCIES_LAYER_ARN_PARAM_NAME = '/sample-lambda-layers-app/shared/npmDependencyLayerArn'; |
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,19 +1,9 @@ | ||
import { Runtime } from '@aws-cdk/aws-lambda'; | ||
import { App, Stack, Stage } from "@aws-cdk/core"; | ||
import { Function, LayerVersion, Code } from '@aws-cdk/aws-lambda'; | ||
import { App } from "@aws-cdk/core"; | ||
import createLambdaLayerStack from './stacks/lambda-layer'; | ||
import createLambdaFunctionStack from './stacks/lambda-function'; | ||
|
||
const app = new App(); | ||
const stack = new Stack(app, "MyStack"); | ||
|
||
const layer = new LayerVersion(stack, 'NpmDependencyLayer', { | ||
code: Code.fromAsset('nodejs.zip'), | ||
compatibleRuntimes: [Runtime.NODEJS_14_X], | ||
description: 'A layer that contains NPM dependencies.', | ||
}); | ||
const app = new App(); | ||
|
||
new Function(stack, 'MyFunction', { | ||
code: Code.fromAsset('src/lambdas'), | ||
runtime: Runtime.NODEJS_14_X, | ||
handler: 'index.handler', | ||
layers: [layer], | ||
}); | ||
createLambdaLayerStack(app); | ||
createLambdaFunctionStack(app); |
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,20 @@ | ||
import { Stack, Construct } from "@aws-cdk/core"; | ||
import { Function, LayerVersion, Code, Runtime } from '@aws-cdk/aws-lambda'; | ||
import { StringParameter } from '@aws-cdk/aws-ssm'; | ||
import { NPM_DEPENDENCIES_LAYER_ARN_PARAM_NAME } from '../constants'; | ||
|
||
export default (scope: Construct) => { | ||
const stack = new Stack(scope, 'LambdaFunctionStack'); | ||
|
||
const npmDependenciesLayerArn = StringParameter.valueForStringParameter(stack, NPM_DEPENDENCIES_LAYER_ARN_PARAM_NAME); | ||
const npmDependenciesLayer = LayerVersion.fromLayerVersionArn(stack, 'NpmDependenciesLayerImport', npmDependenciesLayerArn); | ||
|
||
new Function(stack, 'MyFunction', { | ||
code: Code.fromAsset('src/lambdas'), | ||
runtime: Runtime.NODEJS_14_X, | ||
handler: 'index.handler', | ||
layers: [npmDependenciesLayer], | ||
}); | ||
|
||
return stack; | ||
}; |
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,22 @@ | ||
import { Runtime } from '@aws-cdk/aws-lambda'; | ||
import { Construct, Stack } from "@aws-cdk/core"; | ||
import { LayerVersion, Code } from '@aws-cdk/aws-lambda'; | ||
import { StringParameter } from '@aws-cdk/aws-ssm'; | ||
import { NPM_DEPENDENCIES_LAYER_ARN_PARAM_NAME } from '../constants'; | ||
|
||
export default (scope: Construct) => { | ||
const stack = new Stack(scope, 'LambdaLayerStack'); | ||
|
||
const layer = new LayerVersion(stack, 'NpmDependenciesLayer', { | ||
code: Code.fromAsset('nodejs.zip'), | ||
compatibleRuntimes: [Runtime.NODEJS_14_X], | ||
description: 'A layer that contains NPM dependencies.', | ||
}); | ||
|
||
new StringParameter(stack, 'NpmDependenciesLayerParam', { | ||
parameterName: NPM_DEPENDENCIES_LAYER_ARN_PARAM_NAME, | ||
stringValue: layer.layerVersionArn, | ||
}) | ||
|
||
return stack; | ||
} |
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 |
---|---|---|
|
@@ -214,7 +214,7 @@ | |
"@aws-cdk/core" "1.122.0" | ||
constructs "^3.3.69" | ||
|
||
"@aws-cdk/[email protected]": | ||
"@aws-cdk/[email protected]", "@aws-cdk/aws-ssm@^1.122.0": | ||
version "1.122.0" | ||
resolved "https://registry.yarnpkg.com/@aws-cdk/aws-ssm/-/aws-ssm-1.122.0.tgz#31e5707bc818d1166a858db6a5ddd527061006b0" | ||
integrity sha512-yoB4tUeV8GgA2MylEMAXlJQUbD9mvOUoZk9zTEGmNyjhpTZBGB24YbBfeoqnq2Igh9PfAlNZkPtguGp/tPZVJQ== | ||
|