Skip to content

Commit

Permalink
feat(lambda): python 3.9 runtime (aws#16366)
Browse files Browse the repository at this point in the history
Add Python 3.9 to the list of supported runtimes.

closes: aws#16144 , aws#16355


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
michaelbrewer authored and david-doyle-as24 committed Sep 7, 2021
1 parent 831019d commit 665d038
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ Example with Python:
new Function(this, 'Function', {
code: Code.fromAsset(path.join(__dirname, 'my-python-handler'), {
bundling: {
image: Runtime.PYTHON_3_8.bundlingImage,
image: Runtime.PYTHON_3_9.bundlingImage,
command: [
'bash', '-c',
'pip install -r requirements.txt -t /asset-output && cp -au . /asset-output'
],
},
}),
runtime: Runtime.PYTHON_3_8,
runtime: Runtime.PYTHON_3_9,
handler: 'index.handler',
});
```
Expand All @@ -632,7 +632,7 @@ new Function(this, 'Function', {
command: ['my', 'cool', 'command'],
},
}),
runtime: Runtime.PYTHON_3_8,
runtime: Runtime.PYTHON_3_9,
handler: 'index.handler',
});
```
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ export class Runtime {
supportsCodeGuruProfiling: true,
});

/**
* The Python 3.9 runtime (python3.9)
*/
public static readonly PYTHON_3_9 = new Runtime('python3.9', RuntimeFamily.PYTHON, {
supportsInlineCode: true,
supportsCodeGuruProfiling: true,
});

/**
* The Java 8 runtime (java8)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,56 @@
"PYTHON38ServiceRole3EA86BBE"
]
},
"PYTHON39ServiceRole53E964DF": {
"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"
]
]
}
]
}
},
"PYTHON39143BF976": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "def handler(event, context):\n return \"success\""
},
"Role": {
"Fn::GetAtt": [
"PYTHON39ServiceRole53E964DF",
"Arn"
]
},
"Handler": "index.handler",
"Runtime": "python3.9"
},
"DependsOn": [
"PYTHON39ServiceRole53E964DF"
]
},
"NODEJS14XServiceRole4523ECDB": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -382,6 +432,11 @@
"Ref": "PYTHON38A180AE47"
}
},
"PYTHON39functionName": {
"Value": {
"Ref": "PYTHON39143BF976"
}
},
"NODEJS14XfunctionName": {
"Value": {
"Ref": "NODEJS14X930214A3"
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ const python38 = new Function(stack, 'PYTHON_3_8', {
});
new CfnOutput(stack, 'PYTHON_3_8-functionName', { value: python38.functionName });

const python39 = new Function(stack, 'PYTHON_3_9', {
code: new InlineCode('def handler(event, context):\n return "success"'),
handler: 'index.handler',
runtime: Runtime.PYTHON_3_9,
});
new CfnOutput(stack, 'PYTHON_3_9-functionName', { value: python39.functionName });

const node14xfn = new Function(stack, 'NODEJS_14_X', {
code: new InlineCode('exports.handler = async function(event) { return "success" }'),
handler: 'index.handler',
Expand Down

0 comments on commit 665d038

Please sign in to comment.