diff --git a/packages/@aws-cdk-testing/cli-integ/.gitignore b/packages/@aws-cdk-testing/cli-integ/.gitignore index eb8b474f4ca2a..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.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/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 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;