diff --git a/packages/@aws-cdk/aws-lambda-python/README.md b/packages/@aws-cdk/aws-lambda-python/README.md index f238a3f309410..ca173c7bb5666 100644 --- a/packages/@aws-cdk/aws-lambda-python/README.md +++ b/packages/@aws-cdk/aws-lambda-python/README.md @@ -27,9 +27,9 @@ Define a `PythonFunction`: ```ts new lambda.PythonFunction(this, 'MyFunction', { entry: '/path/to/my/function', // required + runtime: Runtime.PYTHON_3_6, // required index: 'my_index.py', // optional, defaults to 'index.py' handler: 'my_exported_func', // optional, defaults to 'handler' - runtime: Runtime.PYTHON_3_6, // optional, defaults to lambda.Runtime.PYTHON_3_7 }); ``` @@ -86,6 +86,7 @@ layer. ```ts new lambda.PythonFunction(this, 'MyFunction', { entry: '/path/to/my/function', + runtime: Runtime.PYTHON_3_6, layers: [ new lambda.PythonLayerVersion(this, 'MyLayer', { entry: '/path/to/my/layer', // point this to your library's directory diff --git a/packages/@aws-cdk/aws-lambda-python/lib/function.ts b/packages/@aws-cdk/aws-lambda-python/lib/function.ts index 84d21b7564909..1aafeb61149f3 100644 --- a/packages/@aws-cdk/aws-lambda-python/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda-python/lib/function.ts @@ -34,10 +34,8 @@ export interface PythonFunctionProps extends lambda.FunctionOptions { /** * The runtime environment. Only runtimes of the Python family are * supported. - * - * @default lambda.Runtime.PYTHON_3_7 */ - readonly runtime?: lambda.Runtime; + readonly runtime: lambda.Runtime; /** * Determines how asset hash is calculated. Assets will get rebuild and diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.test.ts b/packages/@aws-cdk/aws-lambda-python/test/function.test.ts index c0636329b2ecc..31450f0a7c43c 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/function.test.ts @@ -45,6 +45,7 @@ beforeEach(() => { test('PythonFunction with defaults', () => { new PythonFunction(stack, 'handler', { entry: 'test/lambda-handler', + runtime: Runtime.PYTHON_3_8, }); expect(bundle).toHaveBeenCalledWith(expect.objectContaining({ @@ -62,6 +63,7 @@ test('PythonFunction with index in a subdirectory', () => { entry: 'test/lambda-handler-sub', index: 'inner/custom_index.py', handler: 'custom_handler', + runtime: Runtime.PYTHON_3_8, }); expect(bundle).toHaveBeenCalledWith(expect.objectContaining({ @@ -78,12 +80,14 @@ test('throws when index is not py', () => { expect(() => new PythonFunction(stack, 'Fn', { entry: 'test/lambda-handler', index: 'index.js', + runtime: Runtime.PYTHON_3_8, })).toThrow(/Only Python \(\.py\) index files are supported/); }); test('throws when entry does not exist', () => { expect(() => new PythonFunction(stack, 'Fn', { entry: 'notfound', + runtime: Runtime.PYTHON_3_8, })).toThrow(/Cannot find index file at/); }); @@ -99,6 +103,7 @@ test('allows specifying hash type', () => { entry: 'test/lambda-handler-nodeps', index: 'index.py', handler: 'handler', + runtime: Runtime.PYTHON_3_8, }); new PythonFunction(stack, 'source2', { @@ -106,6 +111,7 @@ test('allows specifying hash type', () => { index: 'index.py', handler: 'handler', assetHashType: AssetHashType.SOURCE, + runtime: Runtime.PYTHON_3_8, }); new PythonFunction(stack, 'output', { @@ -113,6 +119,7 @@ test('allows specifying hash type', () => { index: 'index.py', handler: 'handler', assetHashType: AssetHashType.OUTPUT, + runtime: Runtime.PYTHON_3_8, }); new PythonFunction(stack, 'custom', { @@ -120,6 +127,7 @@ test('allows specifying hash type', () => { index: 'index.py', handler: 'handler', assetHash: 'MY_CUSTOM_HASH', + runtime: Runtime.PYTHON_3_8, }); Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {