Skip to content

Commit d322f0e

Browse files
authored
Add support for python3.9 lambdas (#2774)
1 parent 9f35ae8 commit d322f0e

File tree

12 files changed

+52
-5
lines changed

12 files changed

+52
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Add support for Python 3.9 Lambdas"
4+
}

core/src/software/aws/toolkits/core/lambda/LambdaRuntime.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum class LambdaRuntime(
2727
PYTHON3_6(Runtime.PYTHON3_6),
2828
PYTHON3_7(Runtime.PYTHON3_7),
2929
PYTHON3_8(Runtime.PYTHON3_8),
30+
PYTHON3_9(Runtime.PYTHON3_9, minSamDebugging = "1.28.0", minSamInit = "1.28.0"),
3031
DOTNETCORE2_1(Runtime.DOTNETCORE2_1),
3132
DOTNETCORE3_1(Runtime.DOTNETCORE3_1),
3233
DOTNET5_0(null, minSamInit = "1.16.0", runtimeOverride = "dotnet5.0");

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ideProfileName=2020.2
1212

1313
# Common dependencies
1414
kotlinVersion=1.4.21
15-
awsSdkVersion=2.17.10
15+
awsSdkVersion=2.17.19
1616
coroutinesVersion=1.3.3
1717
detektVersion=1.17.1
1818
jacksonVersion=2.11.1

jetbrains-core/it/software/aws/toolkits/jetbrains/services/lambda/python/PythonLocalLambdaRunConfigurationIntegrationTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class PythonLocalLambdaRunConfigurationIntegrationTest(private val runtime: Runt
4242
arrayOf(Runtime.PYTHON2_7),
4343
arrayOf(Runtime.PYTHON3_6),
4444
arrayOf(Runtime.PYTHON3_7),
45-
arrayOf(Runtime.PYTHON3_8)
45+
arrayOf(Runtime.PYTHON3_8),
46+
arrayOf(Runtime.PYTHON3_9)
4647
)
4748
}
4849

jetbrains-core/resources/META-INF/ext-python.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.python.Python36ImageDebugSupport"/>
2222
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.python.Python37ImageDebugSupport"/>
2323
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.python.Python38ImageDebugSupport"/>
24+
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.python.Python39ImageDebugSupport"/>
2425
<sam.projectWizard id="PYTHON" implementationClass="software.aws.toolkits.jetbrains.services.lambda.python.PythonSamProjectWizard"/>
2526
</extensions>
2627
<extensions defaultExtensionNs="aws.toolkit.clouddebug">

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/python/PythonDebugSupport.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ class Python38ImageDebugSupport : PythonImageDebugSupport() {
100100
override val bootstrapPath: String = "/var/runtime/bootstrap.py"
101101
}
102102

103+
class Python39ImageDebugSupport : PythonImageDebugSupport() {
104+
override val id: String = LambdaRuntime.PYTHON3_9.toString()
105+
override fun displayName() = LambdaRuntime.PYTHON3_9.toString().capitalize()
106+
override val pythonPath: String = "/var/lang/bin/python3.9"
107+
override val bootstrapPath: String = "/var/runtime/bootstrap.py"
108+
}
109+
103110
private const val DEBUGGER_VOLUME_PATH = "/tmp/lambci_debug_files"
104111

105112
private fun createDebugProcess(

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/python/PythonRuntimeGroup.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ class PythonRuntimeGroup : SdkBasedRuntimeGroup() {
2323
LambdaRuntime.PYTHON2_7,
2424
LambdaRuntime.PYTHON3_6,
2525
LambdaRuntime.PYTHON3_7,
26-
LambdaRuntime.PYTHON3_8
26+
LambdaRuntime.PYTHON3_8,
27+
LambdaRuntime.PYTHON3_9
2728
)
2829

2930
override fun runtimeForSdk(sdk: Sdk): LambdaRuntime? = when {
31+
sdk.sdkType is PythonSdkType && PythonSdkType.getLanguageLevelForSdk(sdk).isAtLeast(LanguageLevel.PYTHON39) -> LambdaRuntime.PYTHON3_9
3032
sdk.sdkType is PythonSdkType && PythonSdkType.getLanguageLevelForSdk(sdk).isAtLeast(LanguageLevel.PYTHON38) -> LambdaRuntime.PYTHON3_8
3133
sdk.sdkType is PythonSdkType && PythonSdkType.getLanguageLevelForSdk(sdk).isAtLeast(LanguageLevel.PYTHON37) -> LambdaRuntime.PYTHON3_7
3234
sdk.sdkType is PythonSdkType && PythonSdkType.getLanguageLevelForSdk(sdk).isPy3K -> LambdaRuntime.PYTHON3_6

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/python/PythonSamProjectWizard.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import software.aws.toolkits.jetbrains.services.lambda.wizard.SdkSelector
2121
import software.aws.toolkits.jetbrains.services.lambda.wizard.TemplateParameters
2222
import software.aws.toolkits.resources.message
2323

24-
private val pythonTemplateRuntimes = setOf(LambdaRuntime.PYTHON3_6, LambdaRuntime.PYTHON3_7, LambdaRuntime.PYTHON3_8)
25-
private val eventBridgeTemplateRuntimes = setOf(LambdaRuntime.PYTHON3_6, LambdaRuntime.PYTHON3_7, LambdaRuntime.PYTHON3_8)
24+
private val pythonTemplateRuntimes = setOf(LambdaRuntime.PYTHON3_6, LambdaRuntime.PYTHON3_7, LambdaRuntime.PYTHON3_8, LambdaRuntime.PYTHON3_9)
25+
private val eventBridgeTemplateRuntimes = setOf(LambdaRuntime.PYTHON3_6, LambdaRuntime.PYTHON3_7, LambdaRuntime.PYTHON3_8, LambdaRuntime.PYTHON3_9)
2626

2727
class PythonSamProjectWizard : SamProjectWizard {
2828
override fun createSdkSelectionPanel(projectLocation: TextFieldWithBrowseButton?): SdkSelector = when {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM public.ecr.aws/lambda/python:3.9
2+
3+
COPY app.py requirements.txt ./
4+
5+
RUN python3.9 -m pip install -r requirements.txt
6+
7+
ENV _HANDLER="app.lambda_handler"
8+
9+
# Command can be overwritten by providing a different command in the template directly.
10+
CMD ["app.lambda_handler"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import json
2+
3+
4+
def lambda_handler(event, context):
5+
return {
6+
"statusCode": 200,
7+
"body": {"message": str(event).upper()},
8+
}

0 commit comments

Comments
 (0)