-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use correct runtime versions for Lambda packagers (#35)
The default runtime version was always used in the Lambda packager. This caused the wrong versions of Python libraries to be installed.
- Loading branch information
Showing
7 changed files
with
92 additions
and
6 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
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import { librariesToPackageJson } from '../src'; | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { aws_lambda as lambda } from 'aws-cdk-lib'; | ||
import { Match, Template } from 'aws-cdk-lib/assertions'; | ||
import { librariesToPackageJson, NodejsDependencyPackager } from '../src'; | ||
|
||
test('Inline version parsing', () => { | ||
const packageJson = librariesToPackageJson(['@aws-sdk/[email protected]', 'nothing', 'library@v595']); | ||
|
@@ -10,3 +13,40 @@ test('Inline version parsing', () => { | |
}, | ||
}); | ||
}); | ||
|
||
test('Packager runtime version matches', () => { | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'test'); | ||
|
||
new NodejsDependencyPackager(stack, 'packager 14', { | ||
runtime: lambda.Runtime.NODEJS_14_X, | ||
}); | ||
new NodejsDependencyPackager(stack, 'packager 16', { | ||
runtime: lambda.Runtime.NODEJS_16_X, | ||
}); | ||
new NodejsDependencyPackager(stack, 'packager 18', { | ||
runtime: lambda.Runtime.NODEJS_18_X, | ||
}); | ||
|
||
const template = Template.fromStack(stack); | ||
|
||
template.hasResourceProperties( | ||
'AWS::Lambda::Function', | ||
Match.objectLike({ | ||
Runtime: lambda.Runtime.NODEJS_14_X.name, | ||
}), | ||
); | ||
template.hasResourceProperties( | ||
'AWS::Lambda::Function', | ||
Match.objectLike({ | ||
Runtime: lambda.Runtime.NODEJS_16_X.name, | ||
}), | ||
); | ||
template.hasResourceProperties( | ||
'AWS::Lambda::Function', | ||
Match.objectLike({ | ||
Runtime: lambda.Runtime.NODEJS_18_X.name, | ||
}), | ||
); | ||
}); | ||
|
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,40 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { aws_lambda as lambda } from 'aws-cdk-lib'; | ||
import { Match, Template } from 'aws-cdk-lib/assertions'; | ||
import { PythonDependencyPackager } from '../src'; | ||
|
||
test('Packager runtime version matches', () => { | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'test'); | ||
|
||
new PythonDependencyPackager(stack, 'packager 3.7', { | ||
runtime: lambda.Runtime.PYTHON_3_7, | ||
}); | ||
new PythonDependencyPackager(stack, 'packager 3.8', { | ||
runtime: lambda.Runtime.PYTHON_3_8, | ||
}); | ||
new PythonDependencyPackager(stack, 'packager 3.9', { | ||
runtime: lambda.Runtime.PYTHON_3_9, | ||
}); | ||
|
||
const template = Template.fromStack(stack); | ||
|
||
template.hasResourceProperties( | ||
'AWS::Lambda::Function', | ||
Match.objectLike({ | ||
Runtime: lambda.Runtime.PYTHON_3_7.name, | ||
}), | ||
); | ||
template.hasResourceProperties( | ||
'AWS::Lambda::Function', | ||
Match.objectLike({ | ||
Runtime: lambda.Runtime.PYTHON_3_8.name, | ||
}), | ||
); | ||
template.hasResourceProperties( | ||
'AWS::Lambda::Function', | ||
Match.objectLike({ | ||
Runtime: lambda.Runtime.PYTHON_3_9.name, | ||
}), | ||
); | ||
}); |