Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class KubectlProvider extends Construct implements IKubectlProvider {
role: props.role,
code: lambda.Code.fromAsset(path.join(__dirname, 'kubectl-handler')),
handler: 'index.handler',
runtime: lambda.Runtime.PYTHON_LATEST,
runtime: lambda.Runtime.determineLatestPythonRuntime(this),
// defined only when using private access
vpc,
securityGroups,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class InstanceDrainHook extends Construct {
const fn = new lambda.Function(this, 'Function', {
code: lambda.Code.fromInline(fs.readFileSync(path.join(__dirname, '..', '..', '..', 'custom-resource-handlers', 'dist', 'aws-ecs', 'lambda-source', 'index.py'), { encoding: 'utf-8' })),
handler: 'index.lambda_handler',
runtime: lambda.Runtime.PYTHON_LATEST,
runtime: lambda.Runtime.determineLatestPythonRuntime(this),
// Timeout: some extra margin for additional API calls made by the Lambda,
// up to a maximum of 15 minutes.
timeout: cdk.Duration.seconds(Math.min(drainTime.toSeconds() + 10, 900)),
Expand Down
15 changes: 10 additions & 5 deletions packages/aws-cdk-lib/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@ export class Runtime {
supportsSnapStart: true,
});

/**
* The latest Python version currently available in ALL regions.
*/
public static readonly PYTHON_LATEST = this.PYTHON_3_13;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change.

Copy link
Contributor Author

@alvazjor alvazjor Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has not been released. This static var was introduced recently, to have an alternative similar to NODEJS_LATEST, but that approach has historically had issues and a method is preferred. I am fixing it before we actually release it


/**
* The Java 8 runtime (java8)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Java runtime.
Expand Down Expand Up @@ -342,6 +337,15 @@ export class Runtime {
*/
public static readonly FROM_IMAGE = new Runtime('FROM_IMAGE');

/**
* The latest Python version currently available
*/
// Will ignore the fact that scope is not yet being used, but it will be
// @ts-ignore
public static determineLatestPythonRuntime(scope: Construct): Runtime {
return this.PYTHON_3_13;
}

/**
* The name of this runtime, as expected by the Lambda resource.
*/
Expand Down Expand Up @@ -419,3 +423,4 @@ export function determineLatestNodeRuntime(scope: Construct): Runtime {
const runtimeName = Stack.of(scope).regionalFact(FactName.LATEST_NODE_RUNTIME, Runtime.NODEJS_18_X.name);
return new Runtime(runtimeName, RuntimeFamily.NODEJS, { supportsInlineCode: true, isVariable: true });
}

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class NotificationsResourceHandler extends Construct {
* 1. Unit test Dockerfile: https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/custom-resource-handlers/test/aws-s3/notifications-resource-handler/Dockerfile
* 2. Custom Resource Handler Framework: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-s3/lib/notifications-resource/notifications-resource-handler.ts
*/
Runtime: Runtime.PYTHON_LATEST.name,
Runtime: Runtime.determineLatestPythonRuntime(this).name,
Timeout: 300,
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-s3/test/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ describe('notification', () => {
});

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Runtime: lambda.Runtime.PYTHON_LATEST.name,
Runtime: 'python3.13',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ describe('Custom resource is created that has correct EKS namespace, environment
},
],
MemorySize: 256,
Runtime: lambda.Runtime.PYTHON_LATEST.name,
Runtime: 'python3.13',
Timeout: 30,
});
});
Expand Down Expand Up @@ -1218,7 +1218,7 @@ describe('Custom resource is created that has correct EKS namespace, environment
},
],
MemorySize: 256,
Runtime: lambda.Runtime.PYTHON_LATEST.name,
Runtime: 'python3.13',
Timeout: 30,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe('when custom resource lambda runtime is set by addLambdaRuntime', () =>
// THEN
const template = Template.fromStack(stack);
template.hasResourceProperties('AWS::Lambda::Function', {
Runtime: lambda.Runtime.PYTHON_LATEST.name,
Runtime: 'python3.13',
});
});

Expand Down
Loading