From f51aa29199df663c42189584240b734dc5b54747 Mon Sep 17 00:00:00 2001 From: Sumu Date: Thu, 29 Feb 2024 11:27:25 -0500 Subject: [PATCH 1/5] add regression patch for cli integ fix Signed-off-by: Sumu --- .../cli-integ/resources/cli-regression-patches/v2.130.0/NOTES.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/NOTES.md diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/NOTES.md b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/NOTES.md new file mode 100644 index 0000000000000..d2b0b6c31ba17 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/NOTES.md @@ -0,0 +1 @@ +This patch brings the [fix](https://github.com/aws/aws-cdk/pull/29305) into the regression suite. \ No newline at end of file From 2840d1c080c11c8d89d9294f7f8a9094b0750dec Mon Sep 17 00:00:00 2001 From: Sumu Date: Thu, 29 Feb 2024 11:33:12 -0500 Subject: [PATCH 2/5] add files to be changed Signed-off-by: Sumu --- .../@aws-cdk-testing/cli-integ/.gitignore | 4 +- .../sam_cdk_integ_app/lib/nested-stack.js | 19 +++ .../sam_cdk_integ_app/lib/test-stack.js | 134 ++++++++++++++++++ 3 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/nested-stack.js create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/test-stack.js diff --git a/packages/@aws-cdk-testing/cli-integ/.gitignore b/packages/@aws-cdk-testing/cli-integ/.gitignore index eb8b474f4ca2a..2ca7a39649401 100644 --- a/packages/@aws-cdk-testing/cli-integ/.gitignore +++ b/packages/@aws-cdk-testing/cli-integ/.gitignore @@ -2,7 +2,7 @@ *.js.map *.d.ts !resources/**/* -node_modules +# node_modules dist .LAST_BUILD @@ -17,4 +17,4 @@ nyc.config.js .DS_Store -junit.xml +junit.xml \ No newline at end of file diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/nested-stack.js b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/nested-stack.js new file mode 100644 index 0000000000000..8620fb693e4bf --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/nested-stack.js @@ -0,0 +1,19 @@ +if (process.env.PACKAGE_LAYOUT_VERSION === '1') { + var { NestedStack } = require('@aws-cdk/core'); + var { Function, Runtime, Code } = require('@aws-cdk/aws-lambda'); +} else { + var { NestedStack } = require('aws-cdk-lib'); + var { Function, Runtime, Code } = require('aws-cdk-lib/aws-lambda'); +} + +class NestedStack1 extends NestedStack { + constructor(scope, id, props) { + super(scope, id, props); + new Function(this, 'FunctionPythonRuntime', { + runtime: Runtime.PYTHON_3_12, + code: Code.fromAsset('./src/python/Function'), + handler: 'app.lambda_handler', + }); + } +} +exports.NestedStack1 = NestedStack1; diff --git a/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/test-stack.js b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/test-stack.js new file mode 100644 index 0000000000000..3e9a071de8ff1 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/test-stack.js @@ -0,0 +1,134 @@ +var path = require('path'); +var { NestedStack1 } = require('./nested-stack'); +if (process.env.PACKAGE_LAYOUT_VERSION === '1') { + var { Stack } = require('@aws-cdk/core'); + var { Runtime, LayerVersion, Code, Function, DockerImageFunction, DockerImageCode } = require('@aws-cdk/aws-lambda'); + var { SpecRestApi, ApiDefinition } = require('@aws-cdk/aws-apigateway'); + var { NodejsFunction } = require('@aws-cdk/aws-lambda-nodejs'); + var { GoFunction } = require('@aws-cdk/aws-lambda-go'); + var { PythonFunction, PythonLayerVersion } = require('@aws-cdk/aws-lambda-python'); + var { Role, ServicePrincipal, PolicyStatement } = require('@aws-cdk/aws-iam'); + var { RetentionDays } = require('@aws-cdk/aws-logs'); +} else { + var { Stack } = require('aws-cdk-lib'); + var { Runtime, LayerVersion, Code, Function, DockerImageFunction, DockerImageCode } = require('aws-cdk-lib/aws-lambda'); + var { SpecRestApi, ApiDefinition } = require('aws-cdk-lib/aws-apigateway'); + var { NodejsFunction } = require('aws-cdk-lib/aws-lambda-nodejs'); + var { GoFunction } = require('@aws-cdk/aws-lambda-go-alpha'); + var { PythonFunction, PythonLayerVersion } = require('@aws-cdk/aws-lambda-python-alpha'); + var { Role, ServicePrincipal, PolicyStatement } = require('aws-cdk-lib/aws-iam'); + var { RetentionDays } = require('aws-cdk-lib/aws-logs'); +} + +const isRunningOnCodeBuild = !!process.env.CODEBUILD_BUILD_ID; + +class CDKSupportDemoRootStack extends Stack{ + constructor(scope, id, props) { + super(scope, id, props); + // Python Runtime + // Layers + new PythonLayerVersion(this, 'PythonLayerVersion', { + compatibleRuntimes: [ + Runtime.PYTHON_3_12, + ], + entry: './src/python/Layer', + }); + new LayerVersion(this, 'LayerVersion', { + compatibleRuntimes: [ + Runtime.PYTHON_3_12, + ], + code: Code.fromAsset('./src/python/Layer'), + }); + new LayerVersion(this, 'BundledLayerVersionPythonRuntime', { + compatibleRuntimes: [ + Runtime.PYTHON_3_12, + ], + code: Code.fromAsset('./src/python/Layer', { + bundling: { + command: [ + '/bin/sh', + '-c', + 'rm -rf /tmp/asset-input && mkdir /tmp/asset-input && cp * /tmp/asset-input && cd /tmp/asset-input && pip install -r requirements.txt -t . && mkdir /asset-output/python && cp -R /tmp/asset-input/* /asset-output/python', + ], + image: Runtime.PYTHON_3_12.bundlingImage, + user: 'root', + } + }), + }); + + // ZIP package type Functions + new PythonFunction(this, 'PythonFunction', { + entry: './src/python/Function', + index: 'app.py', + handler: 'lambda_handler', + runtime: Runtime.PYTHON_3_12, + functionName: 'pythonFunc', + logRetention: RetentionDays.THREE_MONTHS, + }); + new Function(this, 'FunctionPythonRuntime', { + runtime: Runtime.PYTHON_3_12, + code: Code.fromAsset('./src/python/Function'), + handler: 'app.lambda_handler', + }); + new Function(this, 'BundledFunctionPythonRuntime', { + runtime: Runtime.PYTHON_3_12, + code: Code.fromAsset('./src/python/Function/', { + bundling: { + command: [ + '/bin/sh', + '-c', + 'rm -rf /tmp/asset-input && mkdir /tmp/asset-input && cp * /tmp/asset-input && cd /tmp/asset-input && pip install -r requirements.txt -t . && cp -R /tmp/asset-input/* /asset-output', + ], + image: Runtime.PYTHON_3_12.bundlingImage, + user: 'root', + } + }), + handler: 'app.lambda_handler', + }); + + // NodeJs Runtime + new NodejsFunction(this, 'NodejsFunction', { + entry: path.join(__dirname, '../src/nodejs/NodeJsFunctionConstruct/app.ts'), + depsLockFilePath: path.join(__dirname, '../src/nodejs/NodeJsFunctionConstruct/package-lock.json'), + bundling: { + forceDockerBundling: true, + }, + handler: 'lambdaHandler', + }); + + // Go Runtime + new GoFunction(this, 'GoFunction', { + entry: './src/go/GoFunctionConstruct', + bundling: { + forcedDockerBundling: true, + // Only use Google proxy in the CI tests, as it is blocked on workstations + goProxies: isRunningOnCodeBuild ? [GoFunction.GOOGLE_GOPROXY, 'direct'] : undefined, + }, + }); + + // Image Package Type Functions + new DockerImageFunction(this, 'DockerImageFunction', { + code: DockerImageCode.fromImageAsset('./src/docker/DockerImageFunctionConstruct', { + file: 'Dockerfile', + }), + }); + + // Spec Rest Api + new SpecRestApi(this, 'SpecRestAPI', { + apiDefinition: ApiDefinition.fromAsset('./src/rest-api-definition.yaml'), + }); + // Role to be used as credentials for the Spec rest APi + // it is used inside the spec rest api definition file + new Role(this, 'SpecRestApiRole', { + assumedBy: new ServicePrincipal('apigateway.amazonaws.com'), + roleName: 'SpecRestApiRole', + }).addToPolicy(new PolicyStatement({ + actions: ['lambda:InvokeFunction'], + resources: ['*'], + })); + + // Nested Stack + new NestedStack1(this, 'NestedStack', {}); + } +} +exports.CDKSupportDemoRootStack = CDKSupportDemoRootStack; From c8d7ac33c464a8fc316ae2378063a549a5ff92b2 Mon Sep 17 00:00:00 2001 From: Sumu Date: Thu, 29 Feb 2024 11:33:51 -0500 Subject: [PATCH 3/5] undo change to gitignore Signed-off-by: Sumu --- packages/@aws-cdk-testing/cli-integ/.gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/.gitignore b/packages/@aws-cdk-testing/cli-integ/.gitignore index 2ca7a39649401..748d96ac7f839 100644 --- a/packages/@aws-cdk-testing/cli-integ/.gitignore +++ b/packages/@aws-cdk-testing/cli-integ/.gitignore @@ -2,7 +2,6 @@ *.js.map *.d.ts !resources/**/* -# node_modules dist .LAST_BUILD @@ -17,4 +16,4 @@ nyc.config.js .DS_Store -junit.xml \ No newline at end of file +junit.xmls \ No newline at end of file From 166d1696087bd8af702df07db1d80fd8efa589fb Mon Sep 17 00:00:00 2001 From: Sumu Date: Thu, 29 Feb 2024 11:34:20 -0500 Subject: [PATCH 4/5] fix gitignore Signed-off-by: Sumu --- packages/@aws-cdk-testing/cli-integ/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@aws-cdk-testing/cli-integ/.gitignore b/packages/@aws-cdk-testing/cli-integ/.gitignore index 748d96ac7f839..987fc625270fc 100644 --- a/packages/@aws-cdk-testing/cli-integ/.gitignore +++ b/packages/@aws-cdk-testing/cli-integ/.gitignore @@ -2,6 +2,7 @@ *.js.map *.d.ts !resources/**/* +node_modules dist .LAST_BUILD From e6bf6e3d413d338fef9e61ce6d63964d8c4f0965 Mon Sep 17 00:00:00 2001 From: Sumu Date: Thu, 29 Feb 2024 11:34:45 -0500 Subject: [PATCH 5/5] fix gitignore junit.xml Signed-off-by: Sumu --- packages/@aws-cdk-testing/cli-integ/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/.gitignore b/packages/@aws-cdk-testing/cli-integ/.gitignore index 987fc625270fc..27bbbe26ae338 100644 --- a/packages/@aws-cdk-testing/cli-integ/.gitignore +++ b/packages/@aws-cdk-testing/cli-integ/.gitignore @@ -17,4 +17,4 @@ nyc.config.js .DS_Store -junit.xmls \ No newline at end of file +junit.xml \ No newline at end of file