From 0ee6fc6853e03bc8e97a654e1ba9fdd413383c9f Mon Sep 17 00:00:00 2001 From: Setu Shah Date: Sat, 5 Dec 2020 22:04:09 -0800 Subject: [PATCH] test(aws-lambda-python): consolidate integration tests for pipenv (#11891) Following the request from @eladb in https://github.com/aws/aws-cdk/pull/11850#pullrequestreview-543829993, consolidating some of the integration tests in the package. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...integ.function.pipenv-inline.expected.json | 110 ------ .../test/integ.function.pipenv-inline.ts | 30 -- .../test/integ.function.pipenv.expected.json | 314 ++++++++++++++++++ .../integ.function.pipenv.py27.expected.json | 110 ------ .../test/integ.function.pipenv.py27.ts | 30 -- .../integ.function.pipenv.py38.expected.json | 110 ------ .../test/integ.function.pipenv.py38.ts | 30 -- .../test/integ.function.pipenv.ts | 45 +++ 8 files changed, 359 insertions(+), 420 deletions(-) delete mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.expected.json delete mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.ts create mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.expected.json delete mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.expected.json delete mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.ts delete mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.expected.json delete mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.ts create mode 100644 packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.ts diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.expected.json b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.expected.json deleted file mode 100644 index 19cc6231599e4..0000000000000 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.expected.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "Resources": { - "myhandlerServiceRole77891068": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "myhandlerD202FA8E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3BucketDF70124D" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3VersionKey530C68B0" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3VersionKey530C68B0" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "index.handler", - "Role": { - "Fn::GetAtt": [ - "myhandlerServiceRole77891068", - "Arn" - ] - }, - "Runtime": "python3.6" - }, - "DependsOn": [ - "myhandlerServiceRole77891068" - ] - } - }, - "Parameters": { - "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3BucketDF70124D": { - "Type": "String", - "Description": "S3 bucket for asset \"eef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255b\"" - }, - "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3VersionKey530C68B0": { - "Type": "String", - "Description": "S3 key for asset version \"eef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255b\"" - }, - "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bArtifactHashEE8E0CE9": { - "Type": "String", - "Description": "Artifact hash for asset \"eef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255b\"" - } - }, - "Outputs": { - "FunctionName": { - "Value": { - "Ref": "myhandlerD202FA8E" - } - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.ts deleted file mode 100644 index ad5db171f719a..0000000000000 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv-inline.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// !cdk-integ pragma:ignore-assets -import * as path from 'path'; -import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as lambda from '../lib'; - -/* - * Stack verification steps: - * aws lambda invoke --function-name --invocation-type Event --payload $(base64 <<<'"OK"') response.json - */ - -class TestStack extends Stack { - constructor(scope: Construct, id: string, props?: StackProps) { - super(scope, id, props); - - const fn = new lambda.PythonFunction(this, 'my_handler', { - entry: path.join(__dirname, 'lambda-handler-pipenv'), - runtime: Runtime.PYTHON_3_6, - }); - - new CfnOutput(this, 'FunctionName', { - value: fn.functionName, - }); - } -} - -const app = new App(); -new TestStack(app, 'cdk-integ-lambda-python-inline'); -app.synth(); diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.expected.json b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.expected.json new file mode 100644 index 0000000000000..0c310b5f52e7e --- /dev/null +++ b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.expected.json @@ -0,0 +1,314 @@ +{ + "Resources": { + "myhandlerinlineServiceRole10C681F6": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "myhandlerinline53D120C7": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Ref": "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3BucketDF70124D" + }, + "S3Key": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3VersionKey530C68B0" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3VersionKey530C68B0" + } + ] + } + ] + } + ] + ] + } + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "myhandlerinlineServiceRole10C681F6", + "Arn" + ] + }, + "Runtime": "python3.6" + }, + "DependsOn": [ + "myhandlerinlineServiceRole10C681F6" + ] + }, + "myhandlerpython27ServiceRole2ED49C06": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "myhandlerpython274D7465EA": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Ref": "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3BucketB5A59BD8" + }, + "S3Key": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3VersionKey7657015C" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3VersionKey7657015C" + } + ] + } + ] + } + ] + ] + } + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "myhandlerpython27ServiceRole2ED49C06", + "Arn" + ] + }, + "Runtime": "python2.7" + }, + "DependsOn": [ + "myhandlerpython27ServiceRole2ED49C06" + ] + }, + "myhandlerpython38ServiceRole2049AFF7": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "myhandlerpython384D62BBB5": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Ref": "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3Bucket31144813" + }, + "S3Key": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3VersionKeyB48E8383" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3VersionKeyB48E8383" + } + ] + } + ] + } + ] + ] + } + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "myhandlerpython38ServiceRole2049AFF7", + "Arn" + ] + }, + "Runtime": "python3.8" + }, + "DependsOn": [ + "myhandlerpython38ServiceRole2049AFF7" + ] + } + }, + "Parameters": { + "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3BucketDF70124D": { + "Type": "String", + "Description": "S3 bucket for asset \"eef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255b\"" + }, + "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bS3VersionKey530C68B0": { + "Type": "String", + "Description": "S3 key for asset version \"eef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255b\"" + }, + "AssetParameterseef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255bArtifactHashEE8E0CE9": { + "Type": "String", + "Description": "Artifact hash for asset \"eef17c074659b655f9b413019323db3976d06067e78d53c4e609ebe177ce255b\"" + }, + "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3BucketB5A59BD8": { + "Type": "String", + "Description": "S3 bucket for asset \"f37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014\"" + }, + "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3VersionKey7657015C": { + "Type": "String", + "Description": "S3 key for asset version \"f37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014\"" + }, + "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014ArtifactHash7768674B": { + "Type": "String", + "Description": "Artifact hash for asset \"f37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014\"" + }, + "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3Bucket31144813": { + "Type": "String", + "Description": "S3 bucket for asset \"3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846a\"" + }, + "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3VersionKeyB48E8383": { + "Type": "String", + "Description": "S3 key for asset version \"3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846a\"" + }, + "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aArtifactHash652F614E": { + "Type": "String", + "Description": "Artifact hash for asset \"3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846a\"" + } + }, + "Outputs": { + "InlineFunctionName": { + "Value": { + "Ref": "myhandlerinline53D120C7" + } + }, + "Python27FunctionName": { + "Value": { + "Ref": "myhandlerpython274D7465EA" + } + }, + "Python38FunctionName": { + "Value": { + "Ref": "myhandlerpython384D62BBB5" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.expected.json b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.expected.json deleted file mode 100644 index c0cb2b260d146..0000000000000 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.expected.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "Resources": { - "myhandlerServiceRole77891068": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "myhandlerD202FA8E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3BucketB5A59BD8" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3VersionKey7657015C" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3VersionKey7657015C" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "index.handler", - "Role": { - "Fn::GetAtt": [ - "myhandlerServiceRole77891068", - "Arn" - ] - }, - "Runtime": "python2.7" - }, - "DependsOn": [ - "myhandlerServiceRole77891068" - ] - } - }, - "Parameters": { - "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3BucketB5A59BD8": { - "Type": "String", - "Description": "S3 bucket for asset \"f37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014\"" - }, - "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014S3VersionKey7657015C": { - "Type": "String", - "Description": "S3 key for asset version \"f37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014\"" - }, - "AssetParametersf37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014ArtifactHash7768674B": { - "Type": "String", - "Description": "Artifact hash for asset \"f37a4de97ca8831930cd2d0dc3f0962e653d756a118ce33271752a745489c014\"" - } - }, - "Outputs": { - "FunctionName": { - "Value": { - "Ref": "myhandlerD202FA8E" - } - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.ts deleted file mode 100644 index e97ca65f8d035..0000000000000 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py27.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// !cdk-integ pragma:ignore-assets -import * as path from 'path'; -import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as lambda from '../lib'; - -/* - * Stack verification steps: - * aws lambda invoke --function-name --invocation-type Event --payload $(base64 <<<'"OK"') response.json - */ - -class TestStack extends Stack { - constructor(scope: Construct, id: string, props?: StackProps) { - super(scope, id, props); - - const fn = new lambda.PythonFunction(this, 'my_handler', { - entry: path.join(__dirname, 'lambda-handler-pipenv'), - runtime: Runtime.PYTHON_2_7, - }); - - new CfnOutput(this, 'FunctionName', { - value: fn.functionName, - }); - } -} - -const app = new App(); -new TestStack(app, 'cdk-integ-lambda-python-pipenv-py27'); -app.synth(); diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.expected.json b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.expected.json deleted file mode 100644 index 07e4ea8cf45f9..0000000000000 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.expected.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "Resources": { - "myhandlerServiceRole77891068": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "myhandlerD202FA8E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3Bucket31144813" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3VersionKeyB48E8383" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3VersionKeyB48E8383" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "index.handler", - "Role": { - "Fn::GetAtt": [ - "myhandlerServiceRole77891068", - "Arn" - ] - }, - "Runtime": "python3.8" - }, - "DependsOn": [ - "myhandlerServiceRole77891068" - ] - } - }, - "Parameters": { - "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3Bucket31144813": { - "Type": "String", - "Description": "S3 bucket for asset \"3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846a\"" - }, - "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aS3VersionKeyB48E8383": { - "Type": "String", - "Description": "S3 key for asset version \"3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846a\"" - }, - "AssetParameters3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846aArtifactHash652F614E": { - "Type": "String", - "Description": "Artifact hash for asset \"3eb927f8df31281e22c710f842018fa10b0dde86f74f89313c9a27db6e75846a\"" - } - }, - "Outputs": { - "FunctionName": { - "Value": { - "Ref": "myhandlerD202FA8E" - } - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.ts deleted file mode 100644 index 75538599ca463..0000000000000 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.py38.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// !cdk-integ pragma:ignore-assets -import * as path from 'path'; -import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as lambda from '../lib'; - -/* - * Stack verification steps: - * aws lambda invoke --function-name --invocation-type Event --payload $(base64 <<<'"OK"') response.json - */ - -class TestStack extends Stack { - constructor(scope: Construct, id: string, props?: StackProps) { - super(scope, id, props); - - const fn = new lambda.PythonFunction(this, 'my_handler', { - entry: path.join(__dirname, 'lambda-handler-pipenv'), - runtime: Runtime.PYTHON_3_8, - }); - - new CfnOutput(this, 'FunctionName', { - value: fn.functionName, - }); - } -} - -const app = new App(); -new TestStack(app, 'cdk-integ-lambda-python-pipenv-py38'); -app.synth(); diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.ts new file mode 100644 index 0000000000000..2b51c5d1efc67 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda-python/test/integ.function.pipenv.ts @@ -0,0 +1,45 @@ +/// !cdk-integ pragma:ignore-assets +import * as path from 'path'; +import { Runtime } from '@aws-cdk/aws-lambda'; +import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; +import * as lambda from '../lib'; + +/* + * Stack verification steps: + * aws lambda invoke --function-name --invocation-type Event --payload $(base64 <<<''OK'') response.json + */ + +class TestStack extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + const pythonFunctionInline = new lambda.PythonFunction(this, 'my_handler_inline', { + entry: path.join(__dirname, 'lambda-handler-pipenv'), + runtime: Runtime.PYTHON_3_6, + }); + new CfnOutput(this, 'InlineFunctionName', { + value: pythonFunctionInline.functionName, + }); + + const pythonFunction27 = new lambda.PythonFunction(this, 'my_handler_python_27', { + entry: path.join(__dirname, 'lambda-handler-pipenv'), + runtime: Runtime.PYTHON_2_7, + }); + new CfnOutput(this, 'Python27FunctionName', { + value: pythonFunction27.functionName, + }); + + const pythonFunction38 = new lambda.PythonFunction(this, 'my_handler_python_38', { + entry: path.join(__dirname, 'lambda-handler-pipenv'), + runtime: Runtime.PYTHON_3_8, + }); + new CfnOutput(this, 'Python38FunctionName', { + value: pythonFunction38.functionName, + }); + } +} + +const app = new App(); +new TestStack(app, 'cdk-integ-lambda-python'); +app.synth();