diff --git a/packages/@aws-cdk/aws-lambda-python/lib/bundling.ts b/packages/@aws-cdk/aws-lambda-python/lib/bundling.ts index 4790b8f08e0eb..726b72c5bc2b8 100644 --- a/packages/@aws-cdk/aws-lambda-python/lib/bundling.ts +++ b/packages/@aws-cdk/aws-lambda-python/lib/bundling.ts @@ -67,6 +67,7 @@ export class Bundling implements CdkBundlingOptions { architecture = Architecture.X86_64, outputPathSuffix = '', image, + poetryIncludeHashes, } = props; const outputPath = path.posix.join(AssetStaging.BUNDLING_OUTPUT_DIR, outputPathSuffix); @@ -75,6 +76,7 @@ export class Bundling implements CdkBundlingOptions { entry, inputDir: AssetStaging.BUNDLING_INPUT_DIR, outputDir: outputPath, + poetryIncludeHashes, }); this.image = image ?? DockerImage.fromBuild(path.join(__dirname, '../lib'), { @@ -89,7 +91,7 @@ export class Bundling implements CdkBundlingOptions { } private createBundlingCommand(options: BundlingCommandOptions): string[] { - const packaging = Packaging.fromEntry(options.entry); + const packaging = Packaging.fromEntry(options.entry, options.poetryIncludeHashes); let bundlingCommands: string[] = []; bundlingCommands.push(`cp -rTL ${options.inputDir}/ ${options.outputDir}`); bundlingCommands.push(`cd ${options.outputDir}`); @@ -105,6 +107,7 @@ interface BundlingCommandOptions { readonly entry: string; readonly inputDir: string; readonly outputDir: string; + readonly poetryIncludeHashes?: boolean; } /** diff --git a/packages/@aws-cdk/aws-lambda-python/lib/packaging.ts b/packages/@aws-cdk/aws-lambda-python/lib/packaging.ts index 55f9118cd3ff1..53cc9f9a23570 100644 --- a/packages/@aws-cdk/aws-lambda-python/lib/packaging.ts +++ b/packages/@aws-cdk/aws-lambda-python/lib/packaging.ts @@ -21,48 +21,73 @@ export interface PackagingProps { readonly exportCommand?: string; } +export interface PoetryPackagingProps { + /** + * Whether to export Poetry dependencies with hashes. Note that this can cause builds to fail if not all dependencies + * export with a hash. + * + * @see https://github.com/aws/aws-cdk/issues/19232 + * @default Hashes are NOT included in the exported `requirements.txt` file + */ + readonly poetryIncludeHashes?: boolean; +} + export class Packaging { /** * Standard packaging with `pip`. */ - public static readonly PIP = new Packaging({ - dependenciesFile: DependenciesFile.PIP, - }); + public static withPip(): Packaging { + return new Packaging({ + dependenciesFile: DependenciesFile.PIP, + }); + } /** * Packaging with `pipenv`. */ - public static readonly PIPENV = new Packaging({ - dependenciesFile: DependenciesFile.PIPENV, - // By default, pipenv creates a virtualenv in `/.local`, so we force it to create one in the package directory. - // At the end, we remove the virtualenv to avoid creating a duplicate copy in the Lambda package. - exportCommand: `PIPENV_VENV_IN_PROJECT=1 pipenv lock -r > ${DependenciesFile.PIP} && rm -rf .venv`, - }); + public static withPipenv(): Packaging { + return new Packaging({ + dependenciesFile: DependenciesFile.PIPENV, + // By default, pipenv creates a virtualenv in `/.local`, so we force it to create one in the package directory. + // At the end, we remove the virtualenv to avoid creating a duplicate copy in the Lambda package. + exportCommand: `PIPENV_VENV_IN_PROJECT=1 pipenv lock -r > ${DependenciesFile.PIP} && rm -rf .venv`, + }); + } /** * Packaging with `poetry`. */ - public static readonly POETRY = new Packaging({ - dependenciesFile: DependenciesFile.POETRY, - // Export dependencies with credentials avaiable in the bundling image. - exportCommand: `poetry export --with-credentials --format ${DependenciesFile.PIP} --output ${DependenciesFile.PIP}`, - }); + public static withPoetry(props?: PoetryPackagingProps) { + return new Packaging({ + dependenciesFile: DependenciesFile.POETRY, + // Export dependencies with credentials available in the bundling image. + exportCommand: [ + 'poetry', 'export', + ...props?.poetryIncludeHashes ? [] : ['--without-hashes'], + '--with-credentials', + '--format', DependenciesFile.PIP, + '--output', DependenciesFile.PIP, + ].join(' '), + }); + } /** * No dependencies or packaging. */ - public static readonly NONE = new Packaging({ dependenciesFile: DependenciesFile.NONE }); + public static withNoPackaging(): Packaging { + return new Packaging({ dependenciesFile: DependenciesFile.NONE }); + } - public static fromEntry(entry: string): Packaging { + public static fromEntry(entry: string, poetryIncludeHashes?: boolean): Packaging { if (fs.existsSync(path.join(entry, DependenciesFile.PIPENV))) { - return Packaging.PIPENV; + return this.withPipenv(); } if (fs.existsSync(path.join(entry, DependenciesFile.POETRY))) { - return Packaging.POETRY; + return this.withPoetry({ poetryIncludeHashes }); } else if (fs.existsSync(path.join(entry, DependenciesFile.PIP))) { - return Packaging.PIP; + return this.withPip(); } else { - return Packaging.NONE; + return this.withNoPackaging(); } } diff --git a/packages/@aws-cdk/aws-lambda-python/lib/types.ts b/packages/@aws-cdk/aws-lambda-python/lib/types.ts index e818eadc4401b..3689c43335959 100644 --- a/packages/@aws-cdk/aws-lambda-python/lib/types.ts +++ b/packages/@aws-cdk/aws-lambda-python/lib/types.ts @@ -5,6 +5,16 @@ import { AssetHashType, DockerImage } from '@aws-cdk/core'; * Options for bundling */ export interface BundlingOptions { + + /** + * Whether to export Poetry dependencies with hashes. Note that this can cause builds to fail if not all dependencies + * export with a hash. + * + * @see https://github.com/aws/aws-cdk/issues/19232 + * @default Hashes are NOT included in the exported `requirements.txt` file + */ + readonly poetryIncludeHashes?: boolean; + /** * Output path suffix: the suffix for the directory into which the bundled output is written. * diff --git a/packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts b/packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts index e9c598d795af7..5626a3f02d2a4 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts @@ -172,6 +172,34 @@ test('Bundling a function with poetry dependencies', () => { outputPathSuffix: 'python', }); + expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({ + bundling: expect.objectContaining({ + command: [ + 'bash', '-c', + 'cp -rTL /asset-input/ /asset-output/python && cd /asset-output/python && poetry export --without-hashes --with-credentials --format requirements.txt --output requirements.txt && python -m pip install -r requirements.txt -t /asset-output/python', + ], + }), + })); + + const files = fs.readdirSync(assetCode.path); + expect(files).toContain('index.py'); + expect(files).toContain('pyproject.toml'); + expect(files).toContain('poetry.lock'); + // Contains hidden files. + expect(files).toContain('.ignorefile'); +}); + +test('Bundling a function with poetry dependencies, with hashes', () => { + const entry = path.join(__dirname, 'lambda-handler-poetry'); + + const assetCode = Bundling.bundle({ + entry: path.join(entry, '.'), + runtime: Runtime.PYTHON_3_9, + architecture: Architecture.X86_64, + outputPathSuffix: 'python', + poetryIncludeHashes: true, + }); + expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({ bundling: expect.objectContaining({ command: [ diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7.bundle/index.js b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb.bundle/index.js similarity index 88% rename from packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7.bundle/index.js rename to packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb.bundle/index.js index ba956d47f51fe..a9e7e7241efc7 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7.bundle/index.js +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb.bundle/index.js @@ -404,20 +404,11 @@ var CustomResourceHandler = class { } async handle() { try { - console.log(`Event: ${JSON.stringify({ ...this.event, ResponseURL: "..." })}`); const response = await this.processEvent(this.event.ResourceProperties); - console.log(`Event output : ${JSON.stringify(response)}`); - await this.respond({ - status: "SUCCESS", - reason: "OK", - data: response - }); + return response; } catch (e) { console.log(e); - await this.respond({ - status: "FAILED", - reason: e.message ?? "Internal Error" - }); + throw e; } finally { clearTimeout(this.timeout); } @@ -479,7 +470,8 @@ var AssertionHandler = class extends CustomResourceHandler { matchResult.finished(); if (matchResult.hasFailed()) { result = { - data: JSON.stringify({ + failed: true, + assertion: JSON.stringify({ status: "fail", message: [ ...matchResult.toHumanStrings(), @@ -488,11 +480,11 @@ var AssertionHandler = class extends CustomResourceHandler { }) }; if (request2.failDeployment) { - throw new Error(result.data); + throw new Error(result.assertion); } } else { result = { - data: JSON.stringify({ + assertion: JSON.stringify({ status: "success" }) }; @@ -562,7 +554,10 @@ function flatten(object) { {}, ...function _flatten(child, path = []) { return [].concat(...Object.keys(child).map((key) => { - const childKey = Buffer.isBuffer(child[key]) ? child[key].toString("utf8") : child[key]; + let childKey = Buffer.isBuffer(child[key]) ? child[key].toString("utf8") : child[key]; + if (typeof childKey === "string") { + childKey = isJsonString(childKey); + } return typeof childKey === "object" && childKey !== null ? _flatten(childKey, path.concat([key])) : { [path.concat([key]).join(".")]: childKey }; })); }(object) @@ -572,6 +567,9 @@ var AwsApiCallHandler = class extends CustomResourceHandler { async processEvent(request2) { const AWS = require("aws-sdk"); console.log(`AWS SDK VERSION: ${AWS.VERSION}`); + if (!Object.prototype.hasOwnProperty.call(AWS, request2.service)) { + throw Error(`Service ${request2.service} does not exist in AWS SDK version ${AWS.VERSION}.`); + } const service = new AWS[request2.service](); const response = await service[request2.api](request2.parameters && decode(request2.parameters)).promise(); console.log(`SDK response received ${JSON.stringify(response)}`); @@ -582,9 +580,18 @@ var AwsApiCallHandler = class extends CustomResourceHandler { const flatData = { ...flatten(respond) }; - return request2.flattenResponse === "true" ? flatData : respond; + const resp = request2.flattenResponse === "true" ? flatData : respond; + console.log(`Returning result ${JSON.stringify(resp)}`); + return resp; } }; +function isJsonString(value) { + try { + return JSON.parse(value); + } catch { + return value; + } +} // lib/assertions/providers/lambda-handler/types.ts var ASSERT_RESOURCE_TYPE = "Custom::DeployAssert@AssertEquals"; @@ -592,18 +599,68 @@ var SDK_RESOURCE_TYPE_PREFIX = "Custom::DeployAssert@SdkCall"; // lib/assertions/providers/lambda-handler/index.ts async function handler(event, context) { + console.log(`Event: ${JSON.stringify({ ...event, ResponseURL: "..." })}`); const provider = createResourceHandler(event, context); - await provider.handle(); + try { + if (event.RequestType === "Delete") { + await provider.respond({ + status: "SUCCESS", + reason: "OK" + }); + return; + } + const result = await provider.handle(); + const actualPath = event.ResourceProperties.actualPath; + const actual = actualPath ? result[`apiCallResponse.${actualPath}`] : result.apiCallResponse; + if ("expected" in event.ResourceProperties) { + const assertion = new AssertionHandler({ + ...event, + ResourceProperties: { + ServiceToken: event.ServiceToken, + actual, + expected: event.ResourceProperties.expected + } + }, context); + try { + const assertionResult = await assertion.handle(); + await provider.respond({ + status: "SUCCESS", + reason: "OK", + data: { + ...assertionResult, + ...result + } + }); + return; + } catch (e) { + await provider.respond({ + status: "FAILED", + reason: e.message ?? "Internal Error" + }); + return; + } + } + await provider.respond({ + status: "SUCCESS", + reason: "OK", + data: result + }); + } catch (e) { + await provider.respond({ + status: "FAILED", + reason: e.message ?? "Internal Error" + }); + return; + } + return; } function createResourceHandler(event, context) { if (event.ResourceType.startsWith(SDK_RESOURCE_TYPE_PREFIX)) { return new AwsApiCallHandler(event, context); - } - switch (event.ResourceType) { - case ASSERT_RESOURCE_TYPE: - return new AssertionHandler(event, context); - default: - throw new Error(`Unsupported resource type "${event.ResourceType}`); + } else if (event.ResourceType.startsWith(ASSERT_RESOURCE_TYPE)) { + return new AssertionHandler(event, context); + } else { + throw new Error(`Unsupported resource type "${event.ResourceType}`); } } // Annotate the CommonJS export names for ESM import in node: diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.assets.json b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.assets.json index 1b2daf3089b55..c1f2d26c393c1 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.assets.json +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.assets.json @@ -1,46 +1,85 @@ { "version": "21.0.0", "files": { - "c61e0f11a70b8ae390550b4477f611d7548cddc58c9a1808b8fa738c84e8849a": { + "08c3ae261768dd649ee56933737731af6e347329cb3e1faae2d767714e16c4ca": { "source": { - "path": "asset.c61e0f11a70b8ae390550b4477f611d7548cddc58c9a1808b8fa738c84e8849a", + "path": "asset.08c3ae261768dd649ee56933737731af6e347329cb3e1faae2d767714e16c4ca", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "c61e0f11a70b8ae390550b4477f611d7548cddc58c9a1808b8fa738c84e8849a.zip", + "objectKey": "08c3ae261768dd649ee56933737731af6e347329cb3e1faae2d767714e16c4ca.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "6d591f099499066675f839dee783892f055c6748cad3ec707031bfb839a7dcf6": { + "14d630e3e802caab7154afce187aade52a56a39aa16c7e510afbfdd6e1e7594e": { "source": { - "path": "asset.6d591f099499066675f839dee783892f055c6748cad3ec707031bfb839a7dcf6", + "path": "asset.14d630e3e802caab7154afce187aade52a56a39aa16c7e510afbfdd6e1e7594e", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "6d591f099499066675f839dee783892f055c6748cad3ec707031bfb839a7dcf6.zip", + "objectKey": "14d630e3e802caab7154afce187aade52a56a39aa16c7e510afbfdd6e1e7594e.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "bc90fc78bab5daff01b73ec5433b085e4324b6956f1c77d320a2d54fb8eb03f1": { + "1b8c70cb81031c22ef2063a87fcf090a5ce97ad10dcd400e98b01d902760ed35": { "source": { - "path": "asset.bc90fc78bab5daff01b73ec5433b085e4324b6956f1c77d320a2d54fb8eb03f1", + "path": "asset.1b8c70cb81031c22ef2063a87fcf090a5ce97ad10dcd400e98b01d902760ed35", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "bc90fc78bab5daff01b73ec5433b085e4324b6956f1c77d320a2d54fb8eb03f1.zip", + "objectKey": "1b8c70cb81031c22ef2063a87fcf090a5ce97ad10dcd400e98b01d902760ed35.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "8112ad5508e2643bdc358860414feb34c0375b34b86dfdaec27fab32c38ea900": { + "b973a843566f0b8fcccb1188a899a6ee551a5a57d9460ee11c6270226fa2c745": { + "source": { + "path": "asset.b973a843566f0b8fcccb1188a899a6ee551a5a57d9460ee11c6270226fa2c745", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "b973a843566f0b8fcccb1188a899a6ee551a5a57d9460ee11c6270226fa2c745.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "65a6feb33ba221a1468300006b7fd9b123b8894e7eeb1be0e63ef23f6cf9b63e": { + "source": { + "path": "asset.65a6feb33ba221a1468300006b7fd9b123b8894e7eeb1be0e63ef23f6cf9b63e", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "65a6feb33ba221a1468300006b7fd9b123b8894e7eeb1be0e63ef23f6cf9b63e.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "12b313bdc8543ea07689a76b42fb9faa74b6dfb6775de53df4e33d1041b8fe12": { + "source": { + "path": "asset.12b313bdc8543ea07689a76b42fb9faa74b6dfb6775de53df4e33d1041b8fe12", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "12b313bdc8543ea07689a76b42fb9faa74b6dfb6775de53df4e33d1041b8fe12.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "531f02a0310a61f667b94d14b955adbdc98e5290659054cb1039dc4e3a147271": { "source": { "path": "integ-lambda-python-poetry.template.json", "packaging": "file" @@ -48,7 +87,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "8112ad5508e2643bdc358860414feb34c0375b34b86dfdaec27fab32c38ea900.json", + "objectKey": "531f02a0310a61f667b94d14b955adbdc98e5290659054cb1039dc4e3a147271.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.template.json b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.template.json index c9954042be36b..572bc92550af7 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.template.json +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/integ-lambda-python-poetry.template.json @@ -38,7 +38,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "c61e0f11a70b8ae390550b4477f611d7548cddc58c9a1808b8fa738c84e8849a.zip" + "S3Key": "08c3ae261768dd649ee56933737731af6e347329cb3e1faae2d767714e16c4ca.zip" }, "Role": { "Fn::GetAtt": [ @@ -53,6 +53,59 @@ "myhandlerinlineServiceRole10C681F6" ] }, + "myhandlerinlinewithhashesServiceRoleDC418F75": { + "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" + ] + ] + } + ] + } + }, + "myhandlerinlinewithhashes352ED54D": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "14d630e3e802caab7154afce187aade52a56a39aa16c7e510afbfdd6e1e7594e.zip" + }, + "Role": { + "Fn::GetAtt": [ + "myhandlerinlinewithhashesServiceRoleDC418F75", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "python3.9" + }, + "DependsOn": [ + "myhandlerinlinewithhashesServiceRoleDC418F75" + ] + }, "myhandlerpython38ServiceRole2049AFF7": { "Type": "AWS::IAM::Role", "Properties": { @@ -91,7 +144,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "6d591f099499066675f839dee783892f055c6748cad3ec707031bfb839a7dcf6.zip" + "S3Key": "1b8c70cb81031c22ef2063a87fcf090a5ce97ad10dcd400e98b01d902760ed35.zip" }, "Role": { "Fn::GetAtt": [ @@ -106,6 +159,59 @@ "myhandlerpython38ServiceRole2049AFF7" ] }, + "myhandlerpython38withhashesServiceRoleFE19CA7C": { + "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" + ] + ] + } + ] + } + }, + "myhandlerpython38withhashesF2275091": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "b973a843566f0b8fcccb1188a899a6ee551a5a57d9460ee11c6270226fa2c745.zip" + }, + "Role": { + "Fn::GetAtt": [ + "myhandlerpython38withhashesServiceRoleFE19CA7C", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "python3.8" + }, + "DependsOn": [ + "myhandlerpython38withhashesServiceRoleFE19CA7C" + ] + }, "myhandlerpython37ServiceRole45CBD18D": { "Type": "AWS::IAM::Role", "Properties": { @@ -144,7 +250,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "bc90fc78bab5daff01b73ec5433b085e4324b6956f1c77d320a2d54fb8eb03f1.zip" + "S3Key": "65a6feb33ba221a1468300006b7fd9b123b8894e7eeb1be0e63ef23f6cf9b63e.zip" }, "Role": { "Fn::GetAtt": [ @@ -158,6 +264,59 @@ "DependsOn": [ "myhandlerpython37ServiceRole45CBD18D" ] + }, + "myhandlerpython37withhashesServiceRoleD9828997": { + "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" + ] + ] + } + ] + } + }, + "myhandlerpython37withhashesE95C48AC": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "12b313bdc8543ea07689a76b42fb9faa74b6dfb6775de53df4e33d1041b8fe12.zip" + }, + "Role": { + "Fn::GetAtt": [ + "myhandlerpython37withhashesServiceRoleD9828997", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "python3.7" + }, + "DependsOn": [ + "myhandlerpython37withhashesServiceRoleD9828997" + ] } }, "Outputs": { @@ -169,6 +328,14 @@ "Name": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerinline53D120C7B0898676" } }, + "ExportsOutputRefmyhandlerinlinewithhashes352ED54DCDE8C1A6": { + "Value": { + "Ref": "myhandlerinlinewithhashes352ED54D" + }, + "Export": { + "Name": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerinlinewithhashes352ED54DCDE8C1A6" + } + }, "ExportsOutputRefmyhandlerpython384D62BBB58AA8B940": { "Value": { "Ref": "myhandlerpython384D62BBB5" @@ -177,6 +344,14 @@ "Name": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython384D62BBB58AA8B940" } }, + "ExportsOutputRefmyhandlerpython38withhashesF2275091B829511A": { + "Value": { + "Ref": "myhandlerpython38withhashesF2275091" + }, + "Export": { + "Name": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython38withhashesF2275091B829511A" + } + }, "ExportsOutputRefmyhandlerpython37C34039A7BB71D94D": { "Value": { "Ref": "myhandlerpython37C34039A7" @@ -184,6 +359,14 @@ "Export": { "Name": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython37C34039A7BB71D94D" } + }, + "ExportsOutputRefmyhandlerpython37withhashesE95C48AC15D1F7B4": { + "Value": { + "Ref": "myhandlerpython37withhashesE95C48AC" + }, + "Export": { + "Name": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython37withhashesE95C48AC15D1F7B4" + } } }, "Parameters": { diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/manifest.json index ca49d8411e8cf..3ed278b19b21d 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/manifest.json @@ -23,7 +23,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8112ad5508e2643bdc358860414feb34c0375b34b86dfdaec27fab32c38ea900.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/531f02a0310a61f667b94d14b955adbdc98e5290659054cb1039dc4e3a147271.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -51,6 +51,18 @@ "data": "myhandlerinline53D120C7" } ], + "/integ-lambda-python-poetry/my_handler_inline_with_hashes/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerinlinewithhashesServiceRoleDC418F75" + } + ], + "/integ-lambda-python-poetry/my_handler_inline_with_hashes/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerinlinewithhashes352ED54D" + } + ], "/integ-lambda-python-poetry/my_handler_python_38/ServiceRole/Resource": [ { "type": "aws:cdk:logicalId", @@ -63,6 +75,18 @@ "data": "myhandlerpython384D62BBB5" } ], + "/integ-lambda-python-poetry/my_handler_python_38_with_hashes/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython38withhashesServiceRoleFE19CA7C" + } + ], + "/integ-lambda-python-poetry/my_handler_python_38_with_hashes/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython38withhashesF2275091" + } + ], "/integ-lambda-python-poetry/my_handler_python_37/ServiceRole/Resource": [ { "type": "aws:cdk:logicalId", @@ -75,24 +99,54 @@ "data": "myhandlerpython37C34039A7" } ], + "/integ-lambda-python-poetry/my_handler_python_37_with_hashes/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython37withhashesServiceRoleD9828997" + } + ], + "/integ-lambda-python-poetry/my_handler_python_37_with_hashes/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython37withhashesE95C48AC" + } + ], "/integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerinline53D120C7\"}": [ { "type": "aws:cdk:logicalId", "data": "ExportsOutputRefmyhandlerinline53D120C7B0898676" } ], + "/integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerinlinewithhashes352ED54D\"}": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsOutputRefmyhandlerinlinewithhashes352ED54DCDE8C1A6" + } + ], "/integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython384D62BBB5\"}": [ { "type": "aws:cdk:logicalId", "data": "ExportsOutputRefmyhandlerpython384D62BBB58AA8B940" } ], + "/integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython38withhashesF2275091\"}": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsOutputRefmyhandlerpython38withhashesF2275091B829511A" + } + ], "/integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython37C34039A7\"}": [ { "type": "aws:cdk:logicalId", "data": "ExportsOutputRefmyhandlerpython37C34039A7BB71D94D" } ], + "/integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython37withhashesE95C48AC\"}": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsOutputRefmyhandlerpython37withhashesE95C48AC15D1F7B4" + } + ], "/integ-lambda-python-poetry/BootstrapVersion": [ { "type": "aws:cdk:logicalId", @@ -104,6 +158,60 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } + ], + "myhandlerinlinenohashesServiceRole792CBFEE": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerinlinenohashesServiceRole792CBFEE", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "myhandlerinlinenohashes9F4AC298": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerinlinenohashes9F4AC298", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "myhandlerpython38nohashesServiceRole95183D41": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython38nohashesServiceRole95183D41", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "myhandlerpython38nohashesAC448740": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython38nohashesAC448740", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "myhandlerpython37nohashesServiceRoleCB0A268B": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython37nohashesServiceRoleCB0A268B", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "myhandlerpython37nohashes751F0455": [ + { + "type": "aws:cdk:logicalId", + "data": "myhandlerpython37nohashes751F0455", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } ] }, "displayName": "integ-lambda-python-poetry" @@ -124,7 +232,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6124f12c447c253e12d289b2cbb005676d5dd3f56d70cb3213d2c534caae16cc.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/01462ebb52e8f49b3e2b2706bba447690a46e44b6f000448dac39836d7ccdd8f.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -153,16 +261,10 @@ "data": "LambdaInvoke81c9998b1b428b309c8501e21b919d3dInvokeEBA46CA4" } ], - "/poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/Default/Default": [ - { - "type": "aws:cdk:logicalId", - "data": "LambdaInvoke81c9998b1b428b309c8501e21b919d3dAssertEqualsLambdainvoke0BDD9934" - } - ], - "/poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/AssertionResults": [ + "/poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertionResults": [ { "type": "aws:cdk:logicalId", - "data": "AssertionResultsAssertEqualsLambdainvoke7418f30d48b25a0240557aece0f9bcb3" + "data": "AssertionResultsLambdaInvoke81c9998b1b428b309c8501e21b919d3d" } ], "/poetry/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role": [ @@ -177,6 +279,24 @@ "data": "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F" } ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8" + } + ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/Invoke": [ + { + "type": "aws:cdk:logicalId", + "data": "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8InvokeEA59DC11" + } + ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsLambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8" + } + ], "/poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/Default/Default": [ { "type": "aws:cdk:logicalId", @@ -189,16 +309,28 @@ "data": "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292InvokeFD76DE7B" } ], - "/poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/Default/Default": [ + "/poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsLambdaInvoke9a0beb4ea6cc38db92e9ff664c085292" + } + ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/Default/Default": [ { "type": "aws:cdk:logicalId", - "data": "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292AssertEqualsLambdainvoke3F6858A2" + "data": "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e" } ], - "/poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/AssertionResults": [ + "/poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/Invoke": [ { "type": "aws:cdk:logicalId", - "data": "AssertionResultsAssertEqualsLambdainvoke3a1682daaa67c2d3f1c57ad30bb121be" + "data": "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39eInvoke930611A4" + } + ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsLambdaInvoke26497bb1c12c14ed3deada8d7d76b39e" } ], "/poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/Default/Default": [ @@ -213,16 +345,28 @@ "data": "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75Invoke11F9A252" } ], - "/poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/Default/Default": [ + "/poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsLambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75" + } + ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89" + } + ], + "/poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/Invoke": [ { "type": "aws:cdk:logicalId", - "data": "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75AssertEqualsLambdainvoke2346EE1F" + "data": "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89Invoke884F6CA8" } ], - "/poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/AssertionResults": [ + "/poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/AssertionResults": [ { "type": "aws:cdk:logicalId", - "data": "AssertionResultsAssertEqualsLambdainvoke71fd18c839842d08b4fd70cd8691cb1f" + "data": "AssertionResultsLambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89" } ], "/poetry/DefaultTest/DeployAssert/BootstrapVersion": [ diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.assets.json b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.assets.json index 1d5bf07a5344f..c1f5ffea39539 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.assets.json +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.assets.json @@ -1,20 +1,20 @@ { "version": "21.0.0", "files": { - "84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7": { + "d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb": { "source": { - "path": "asset.84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7.bundle", + "path": "asset.d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb.bundle", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7.zip", + "objectKey": "d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "6124f12c447c253e12d289b2cbb005676d5dd3f56d70cb3213d2c534caae16cc": { + "01462ebb52e8f49b3e2b2706bba447690a46e44b6f000448dac39836d7ccdd8f": { "source": { "path": "poetryDefaultTestDeployAssertE9C9CB8F.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "6124f12c447c253e12d289b2cbb005676d5dd3f56d70cb3213d2c534caae16cc.json", + "objectKey": "01462ebb52e8f49b3e2b2706bba447690a46e44b6f000448dac39836d7ccdd8f.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.template.json b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.template.json index 634e3f92ddaf6..14f2e1c399cea 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.template.json +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/poetryDefaultTestDeployAssertE9C9CB8F.template.json @@ -11,13 +11,14 @@ }, "service": "Lambda", "api": "invoke", + "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", "parameters": { "FunctionName": { "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerinline53D120C7B0898676" } }, "flattenResponse": "false", - "salt": "1662643425337" + "salt": "1665153703471" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -37,27 +38,6 @@ } } }, - "LambdaInvoke81c9998b1b428b309c8501e21b919d3dAssertEqualsLambdainvoke0BDD9934": { - "Type": "Custom::DeployAssert@AssertEquals", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", - "Arn" - ] - }, - "actual": { - "Fn::GetAtt": [ - "LambdaInvoke81c9998b1b428b309c8501e21b919d3d", - "apiCallResponse" - ] - }, - "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", - "salt": "1662643425338" - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": { "Type": "AWS::IAM::Role", "Properties": { @@ -133,6 +113,46 @@ "*" ] }, + { + "Action": [ + "lambda:InvokeFunction" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":lambda:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":function:", + { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerinlinewithhashes352ED54DCDE8C1A6" + } + ] + ] + } + ] + }, + { + "Action": [ + "lambda:Invoke" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + }, { "Action": [ "lambda:InvokeFunction" @@ -173,6 +193,46 @@ "*" ] }, + { + "Action": [ + "lambda:InvokeFunction" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":lambda:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":function:", + { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython38withhashesF2275091B829511A" + } + ] + ] + } + ] + }, + { + "Action": [ + "lambda:Invoke" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + }, { "Action": [ "lambda:InvokeFunction" @@ -203,6 +263,46 @@ ] } ] + }, + { + "Action": [ + "lambda:Invoke" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + }, + { + "Action": [ + "lambda:InvokeFunction" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":lambda:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":function:", + { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython37withhashesE95C48AC15D1F7B4" + } + ] + ] + } + ] } ] } @@ -218,7 +318,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "84802aa01d2d2c9e7d8d69705ee832c97f1ebad2d73c72be5c32d53f16cf90a7.zip" + "S3Key": "d47f7e6772bfdf47ecbc070ffe204baf53bacbfbf7814eb407bd8ea108c1c1bb.zip" }, "Timeout": 120, "Handler": "index.handler", @@ -230,6 +330,44 @@ } } }, + "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8": { + "Type": "Custom::DeployAssert@SdkCallLambdainvoke", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "service": "Lambda", + "api": "invoke", + "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", + "parameters": { + "FunctionName": { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerinlinewithhashes352ED54DCDE8C1A6" + } + }, + "flattenResponse": "false", + "salt": "1665153703472" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8InvokeEA59DC11": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerinlinewithhashes352ED54DCDE8C1A6" + }, + "Principal": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", + "Arn" + ] + } + } + }, "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292": { "Type": "Custom::DeployAssert@SdkCallLambdainvoke", "Properties": { @@ -241,13 +379,14 @@ }, "service": "Lambda", "api": "invoke", + "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", "parameters": { "FunctionName": { "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython384D62BBB58AA8B940" } }, "flattenResponse": "false", - "salt": "1662643425339" + "salt": "1665153703472" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -267,8 +406,8 @@ } } }, - "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292AssertEqualsLambdainvoke3F6858A2": { - "Type": "Custom::DeployAssert@AssertEquals", + "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e": { + "Type": "Custom::DeployAssert@SdkCallLambdainvoke", "Properties": { "ServiceToken": { "Fn::GetAtt": [ @@ -276,18 +415,35 @@ "Arn" ] }, - "actual": { - "Fn::GetAtt": [ - "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292", - "apiCallResponse" - ] - }, + "service": "Lambda", + "api": "invoke", "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", - "salt": "1662643425339" + "parameters": { + "FunctionName": { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython38withhashesF2275091B829511A" + } + }, + "flattenResponse": "false", + "salt": "1665153703472" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, + "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39eInvoke930611A4": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython38withhashesF2275091B829511A" + }, + "Principal": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", + "Arn" + ] + } + } + }, "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75": { "Type": "Custom::DeployAssert@SdkCallLambdainvoke", "Properties": { @@ -299,13 +455,14 @@ }, "service": "Lambda", "api": "invoke", + "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", "parameters": { "FunctionName": { "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython37C34039A7BB71D94D" } }, "flattenResponse": "false", - "salt": "1662643425339" + "salt": "1665153703472" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -325,8 +482,8 @@ } } }, - "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75AssertEqualsLambdainvoke2346EE1F": { - "Type": "Custom::DeployAssert@AssertEquals", + "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89": { + "Type": "Custom::DeployAssert@SdkCallLambdainvoke", "Properties": { "ServiceToken": { "Fn::GetAtt": [ @@ -334,41 +491,82 @@ "Arn" ] }, - "actual": { - "Fn::GetAtt": [ - "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75", - "apiCallResponse" - ] - }, + "service": "Lambda", + "api": "invoke", "expected": "{\"$ObjectLike\":{\"Payload\":\"200\"}}", - "salt": "1662643425339" + "parameters": { + "FunctionName": { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython37withhashesE95C48AC15D1F7B4" + } + }, + "flattenResponse": "false", + "salt": "1665153703472" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" + }, + "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89Invoke884F6CA8": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::ImportValue": "integ-lambda-python-poetry:ExportsOutputRefmyhandlerpython37withhashesE95C48AC15D1F7B4" + }, + "Principal": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", + "Arn" + ] + } + } } }, "Outputs": { - "AssertionResultsAssertEqualsLambdainvoke7418f30d48b25a0240557aece0f9bcb3": { + "AssertionResultsLambdaInvoke81c9998b1b428b309c8501e21b919d3d": { + "Value": { + "Fn::GetAtt": [ + "LambdaInvoke81c9998b1b428b309c8501e21b919d3d", + "assertion" + ] + } + }, + "AssertionResultsLambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8": { + "Value": { + "Fn::GetAtt": [ + "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8", + "assertion" + ] + } + }, + "AssertionResultsLambdaInvoke9a0beb4ea6cc38db92e9ff664c085292": { + "Value": { + "Fn::GetAtt": [ + "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292", + "assertion" + ] + } + }, + "AssertionResultsLambdaInvoke26497bb1c12c14ed3deada8d7d76b39e": { "Value": { "Fn::GetAtt": [ - "LambdaInvoke81c9998b1b428b309c8501e21b919d3dAssertEqualsLambdainvoke0BDD9934", - "data" + "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e", + "assertion" ] } }, - "AssertionResultsAssertEqualsLambdainvoke3a1682daaa67c2d3f1c57ad30bb121be": { + "AssertionResultsLambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75": { "Value": { "Fn::GetAtt": [ - "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292AssertEqualsLambdainvoke3F6858A2", - "data" + "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75", + "assertion" ] } }, - "AssertionResultsAssertEqualsLambdainvoke71fd18c839842d08b4fd70cd8691cb1f": { + "AssertionResultsLambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89": { "Value": { "Fn::GetAtt": [ - "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75AssertEqualsLambdainvoke2346EE1F", - "data" + "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89", + "assertion" ] } } diff --git a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/tree.json b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/tree.json index 79fdc9449e9f8..3d1428fb4d593 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/tree.json @@ -9,7 +9,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } }, "integ-lambda-python-poetry": { @@ -105,7 +105,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "c61e0f11a70b8ae390550b4477f611d7548cddc58c9a1808b8fa738c84e8849a.zip" + "s3Key": "08c3ae261768dd649ee56933737731af6e347329cb3e1faae2d767714e16c4ca.zip" }, "role": { "Fn::GetAtt": [ @@ -128,6 +128,118 @@ "version": "0.0.0" } }, + "my_handler_inline_with_hashes": { + "id": "my_handler_inline_with_hashes", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "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" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Code": { + "id": "Code", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes/Code", + "children": { + "Stage": { + "id": "Stage", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes/Code/Stage", + "constructInfo": { + "fqn": "@aws-cdk/core.AssetStaging", + "version": "0.0.0" + } + }, + "AssetBucket": { + "id": "AssetBucket", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes/Code/AssetBucket", + "constructInfo": { + "fqn": "@aws-cdk/aws-s3.BucketBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-s3-assets.Asset", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-lambda-python-poetry/my_handler_inline_with_hashes/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "s3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "s3Key": "14d630e3e802caab7154afce187aade52a56a39aa16c7e510afbfdd6e1e7594e.zip" + }, + "role": { + "Fn::GetAtt": [ + "myhandlerinlinewithhashesServiceRoleDC418F75", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "python3.9" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda-python.PythonFunction", + "version": "0.0.0" + } + }, "my_handler_python_38": { "id": "my_handler_python_38", "path": "integ-lambda-python-poetry/my_handler_python_38", @@ -217,7 +329,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "6d591f099499066675f839dee783892f055c6748cad3ec707031bfb839a7dcf6.zip" + "s3Key": "1b8c70cb81031c22ef2063a87fcf090a5ce97ad10dcd400e98b01d902760ed35.zip" }, "role": { "Fn::GetAtt": [ @@ -240,6 +352,118 @@ "version": "0.0.0" } }, + "my_handler_python_38_with_hashes": { + "id": "my_handler_python_38_with_hashes", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "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" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Code": { + "id": "Code", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes/Code", + "children": { + "Stage": { + "id": "Stage", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes/Code/Stage", + "constructInfo": { + "fqn": "@aws-cdk/core.AssetStaging", + "version": "0.0.0" + } + }, + "AssetBucket": { + "id": "AssetBucket", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes/Code/AssetBucket", + "constructInfo": { + "fqn": "@aws-cdk/aws-s3.BucketBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-s3-assets.Asset", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-lambda-python-poetry/my_handler_python_38_with_hashes/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "s3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "s3Key": "b973a843566f0b8fcccb1188a899a6ee551a5a57d9460ee11c6270226fa2c745.zip" + }, + "role": { + "Fn::GetAtt": [ + "myhandlerpython38withhashesServiceRoleFE19CA7C", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "python3.8" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda-python.PythonFunction", + "version": "0.0.0" + } + }, "my_handler_python_37": { "id": "my_handler_python_37", "path": "integ-lambda-python-poetry/my_handler_python_37", @@ -329,7 +553,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "bc90fc78bab5daff01b73ec5433b085e4324b6956f1c77d320a2d54fb8eb03f1.zip" + "s3Key": "65a6feb33ba221a1468300006b7fd9b123b8894e7eeb1be0e63ef23f6cf9b63e.zip" }, "role": { "Fn::GetAtt": [ @@ -352,6 +576,118 @@ "version": "0.0.0" } }, + "my_handler_python_37_with_hashes": { + "id": "my_handler_python_37_with_hashes", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes/ServiceRole", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "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" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Code": { + "id": "Code", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes/Code", + "children": { + "Stage": { + "id": "Stage", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes/Code/Stage", + "constructInfo": { + "fqn": "@aws-cdk/core.AssetStaging", + "version": "0.0.0" + } + }, + "AssetBucket": { + "id": "AssetBucket", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes/Code/AssetBucket", + "constructInfo": { + "fqn": "@aws-cdk/aws-s3.BucketBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-s3-assets.Asset", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-lambda-python-poetry/my_handler_python_37_with_hashes/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "s3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "s3Key": "12b313bdc8543ea07689a76b42fb9faa74b6dfb6775de53df4e33d1041b8fe12.zip" + }, + "role": { + "Fn::GetAtt": [ + "myhandlerpython37withhashesServiceRoleD9828997", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "python3.7" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda-python.PythonFunction", + "version": "0.0.0" + } + }, "Exports": { "id": "Exports", "path": "integ-lambda-python-poetry/Exports", @@ -364,6 +700,14 @@ "version": "0.0.0" } }, + "Output{\"Ref\":\"myhandlerinlinewithhashes352ED54D\"}": { + "id": "Output{\"Ref\":\"myhandlerinlinewithhashes352ED54D\"}", + "path": "integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerinlinewithhashes352ED54D\"}", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + }, "Output{\"Ref\":\"myhandlerpython384D62BBB5\"}": { "id": "Output{\"Ref\":\"myhandlerpython384D62BBB5\"}", "path": "integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython384D62BBB5\"}", @@ -372,6 +716,14 @@ "version": "0.0.0" } }, + "Output{\"Ref\":\"myhandlerpython38withhashesF2275091\"}": { + "id": "Output{\"Ref\":\"myhandlerpython38withhashesF2275091\"}", + "path": "integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython38withhashesF2275091\"}", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + }, "Output{\"Ref\":\"myhandlerpython37C34039A7\"}": { "id": "Output{\"Ref\":\"myhandlerpython37C34039A7\"}", "path": "integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython37C34039A7\"}", @@ -379,11 +731,19 @@ "fqn": "@aws-cdk/core.CfnOutput", "version": "0.0.0" } + }, + "Output{\"Ref\":\"myhandlerpython37withhashesE95C48AC\"}": { + "id": "Output{\"Ref\":\"myhandlerpython37withhashesE95C48AC\"}", + "path": "integ-lambda-python-poetry/Exports/Output{\"Ref\":\"myhandlerpython37withhashesE95C48AC\"}", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } } }, @@ -405,7 +765,7 @@ "path": "poetry/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } }, "DeployAssert": { @@ -425,13 +785,13 @@ "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" } }, "Default": { @@ -460,64 +820,18 @@ "version": "0.0.0" } }, - "AssertEqualsLambdainvoke": { - "id": "AssertEqualsLambdainvoke", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke", - "children": { - "AssertionProvider": { - "id": "AssertionProvider", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/AssertionProvider", - "children": { - "AssertionsProvider": { - "id": "AssertionsProvider", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/AssertionProvider/AssertionsProvider", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" - } - } - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" - } - }, - "Default": { - "id": "Default", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/Default", - "children": { - "Default": { - "id": "Default", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/Default/Default", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnResource", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.CustomResource", - "version": "0.0.0" - } - }, - "AssertionResults": { - "id": "AssertionResults", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertEqualsLambdainvoke/AssertionResults", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnOutput", - "version": "0.0.0" - } - } - }, + "AssertionResults": { + "id": "AssertionResults", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke81c9998b1b428b309c8501e21b919d3d/AssertionResults", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.LambdaInvokeFunction", + "version": "0.0.0" } }, "SingletonFunction1488541a7b23466481b69b4408076b81": { @@ -551,7 +865,69 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" + } + }, + "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8": { + "id": "LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/SdkProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/SdkProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.123" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/Default", + "children": { + "Default": { + "id": "Default", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/Default/Default", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.CustomResource", + "version": "0.0.0" + } + }, + "Invoke": { + "id": "Invoke", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/Invoke", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke82a73e0d5d0fdcb04565e4d81ef342b8/AssertionResults", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.LambdaInvokeFunction", + "version": "0.0.0" } }, "LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292": { @@ -567,13 +943,13 @@ "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" } }, "Default": { @@ -602,64 +978,80 @@ "version": "0.0.0" } }, - "AssertEqualsLambdainvoke": { - "id": "AssertEqualsLambdainvoke", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke", + "AssertionResults": { + "id": "AssertionResults", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertionResults", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.LambdaInvokeFunction", + "version": "0.0.0" + } + }, + "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e": { + "id": "LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/SdkProvider", "children": { - "AssertionProvider": { - "id": "AssertionProvider", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/AssertionProvider", - "children": { - "AssertionsProvider": { - "id": "AssertionsProvider", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/AssertionProvider/AssertionsProvider", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" - } - } - }, + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } - }, + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/Default", + "children": { "Default": { "id": "Default", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/Default", - "children": { - "Default": { - "id": "Default", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/Default/Default", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnResource", - "version": "0.0.0" - } - } - }, + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/Default/Default", "constructInfo": { - "fqn": "@aws-cdk/core.CustomResource", - "version": "0.0.0" - } - }, - "AssertionResults": { - "id": "AssertionResults", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke9a0beb4ea6cc38db92e9ff664c085292/AssertEqualsLambdainvoke/AssertionResults", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnOutput", + "fqn": "@aws-cdk/core.CfnResource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/core.CustomResource", + "version": "0.0.0" + } + }, + "Invoke": { + "id": "Invoke", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/Invoke", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke26497bb1c12c14ed3deada8d7d76b39e/AssertionResults", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.LambdaInvokeFunction", + "version": "0.0.0" } }, "LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75": { @@ -675,13 +1067,13 @@ "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" } }, "Default": { @@ -710,64 +1102,80 @@ "version": "0.0.0" } }, - "AssertEqualsLambdainvoke": { - "id": "AssertEqualsLambdainvoke", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke", + "AssertionResults": { + "id": "AssertionResults", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertionResults", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.LambdaInvokeFunction", + "version": "0.0.0" + } + }, + "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89": { + "id": "LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/SdkProvider", "children": { - "AssertionProvider": { - "id": "AssertionProvider", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/AssertionProvider", - "children": { - "AssertionsProvider": { - "id": "AssertionsProvider", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/AssertionProvider/AssertionsProvider", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" - } - } - }, + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.95" + "version": "10.1.123" } - }, + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/Default", + "children": { "Default": { "id": "Default", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/Default", - "children": { - "Default": { - "id": "Default", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/Default/Default", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnResource", - "version": "0.0.0" - } - } - }, + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/Default/Default", "constructInfo": { - "fqn": "@aws-cdk/core.CustomResource", - "version": "0.0.0" - } - }, - "AssertionResults": { - "id": "AssertionResults", - "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke631dde0680edf7d2f0eea8d9b9c06c75/AssertEqualsLambdainvoke/AssertionResults", - "constructInfo": { - "fqn": "@aws-cdk/core.CfnOutput", + "fqn": "@aws-cdk/core.CfnResource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/core.CustomResource", + "version": "0.0.0" + } + }, + "Invoke": { + "id": "Invoke", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/Invoke", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "poetry/DefaultTest/DeployAssert/LambdaInvoke8cbaf98b5be6e4f6f81f5f10b5b8dc89/AssertionResults", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.LambdaInvokeFunction", + "version": "0.0.0" } } }, @@ -778,14 +1186,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.95" + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" } } }, diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.poetry.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.poetry.ts index 162edff2db14c..64ef3a8da3a70 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.poetry.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/integ.function.poetry.ts @@ -21,18 +21,45 @@ class TestStack extends Stack { }); this.functionNames.push(pythonFunction39.functionName); + const pythonFunction39WithHashes = new lambda.PythonFunction(this, 'my_handler_inline_with_hashes', { + entry: path.join(__dirname, 'lambda-handler-poetry'), + runtime: Runtime.PYTHON_3_9, + bundling: { + poetryIncludeHashes: true, + }, + }); + this.functionNames.push(pythonFunction39WithHashes.functionName); + const pythonFunction38 = new lambda.PythonFunction(this, 'my_handler_python_38', { entry: path.join(__dirname, 'lambda-handler-poetry'), runtime: Runtime.PYTHON_3_8, }); this.functionNames.push(pythonFunction38.functionName); + const pythonFunction38WithHashes = new lambda.PythonFunction(this, 'my_handler_python_38_with_hashes', { + entry: path.join(__dirname, 'lambda-handler-poetry'), + runtime: Runtime.PYTHON_3_8, + bundling: { + poetryIncludeHashes: true, + }, + }); + this.functionNames.push(pythonFunction38WithHashes.functionName); + const pythonFunction37 = new lambda.PythonFunction(this, 'my_handler_python_37', { entry: path.join(__dirname, 'lambda-handler-poetry'), runtime: Runtime.PYTHON_3_7, }); this.functionNames.push(pythonFunction37.functionName); + const pythonFunction37WithHashes = new lambda.PythonFunction(this, 'my_handler_python_37_with_hashes', { + entry: path.join(__dirname, 'lambda-handler-poetry'), + runtime: Runtime.PYTHON_3_7, + bundling: { + poetryIncludeHashes: true, + }, + }); + this.functionNames.push(pythonFunction37WithHashes.functionName); + } } diff --git a/packages/@aws-cdk/aws-lambda-python/test/packaging.test.ts b/packages/@aws-cdk/aws-lambda-python/test/packaging.test.ts index 5cedd42b941bc..4054bd082f131 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/packaging.test.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/packaging.test.ts @@ -6,7 +6,7 @@ test('Packging with no dependencies', () => { const packaging = Packaging.fromEntry(entry); // pip packaging identified. - expect(packaging).toEqual(Packaging.NONE); + expect(packaging).toEqual(Packaging.withNoPackaging()); }); test('Packging with requirements.txt', () => { @@ -14,7 +14,7 @@ test('Packging with requirements.txt', () => { const packaging = Packaging.fromEntry(entry); // pip packaging identified. - expect(packaging).toEqual(Packaging.PIP); + expect(packaging).toEqual(Packaging.withPip()); }); test('Packging with pipenv', () => { @@ -22,7 +22,7 @@ test('Packging with pipenv', () => { const packaging = Packaging.fromEntry(entry); // pip packaging identified. - expect(packaging).toEqual(Packaging.PIPENV); + expect(packaging).toEqual(Packaging.withPipenv()); }); test('Packging with poetry', () => { @@ -30,5 +30,5 @@ test('Packging with poetry', () => { const packaging = Packaging.fromEntry(entry); // pip packaging identified. - expect(packaging).toEqual(Packaging.POETRY); + expect(packaging).toEqual(Packaging.withPoetry()); });