-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lambda-python): add support for custom build image
- Loading branch information
Showing
17 changed files
with
390 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
packages/@aws-cdk/aws-lambda-python/test/integ.function.custom-build.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"Resources": { | ||
"myhandlerServiceRole77891068": { | ||
"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" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"myhandlerD202FA8E": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": { | ||
"Ref": "AssetParameters1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4S3BucketEBE184E0" | ||
}, | ||
"S3Key": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::Select": [ | ||
0, | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Ref": "AssetParameters1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4S3VersionKey975132EB" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Fn::Select": [ | ||
1, | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Ref": "AssetParameters1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4S3VersionKey975132EB" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"myhandlerServiceRole77891068", | ||
"Arn" | ||
] | ||
}, | ||
"Handler": "index.handler", | ||
"Runtime": "python3.8" | ||
}, | ||
"DependsOn": [ | ||
"myhandlerServiceRole77891068" | ||
] | ||
} | ||
}, | ||
"Parameters": { | ||
"AssetParameters1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4S3BucketEBE184E0": { | ||
"Type": "String", | ||
"Description": "S3 bucket for asset \"1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4\"" | ||
}, | ||
"AssetParameters1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4S3VersionKey975132EB": { | ||
"Type": "String", | ||
"Description": "S3 key for asset version \"1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4\"" | ||
}, | ||
"AssetParameters1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4ArtifactHash8A22CFFB": { | ||
"Type": "String", | ||
"Description": "Artifact hash for asset \"1a7117630f60ba58bbd781ad2b5943188bcd1890aab87f5544c0d058012961c4\"" | ||
} | ||
}, | ||
"Outputs": { | ||
"FunctionArn": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"myhandlerD202FA8E", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/@aws-cdk/aws-lambda-python/test/integ.function.custom-build.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as path from 'path'; | ||
import { Runtime } from '@aws-cdk/aws-lambda'; | ||
import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; | ||
import { Construct } from 'constructs'; | ||
import * as lambda from '../lib'; | ||
|
||
/* | ||
* Stack verification steps: | ||
* * aws lambda invoke --function-name <deployed fn name> --invocation-type Event --payload '"OK"' response.json | ||
*/ | ||
|
||
class TestStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const fn = new lambda.PythonFunction(this, 'my_handler', { | ||
entry: path.join(__dirname, 'lambda-handler-custom-build-docker-image'), | ||
runtime: Runtime.PYTHON_3_8, | ||
dockerBuildImageOptions: { file: 'Dockerfile.build' }, | ||
}); | ||
|
||
new CfnOutput(this, 'FunctionArn', { | ||
value: fn.functionArn, | ||
}); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
new TestStack(app, 'cdk-integ-lambda-python'); | ||
app.synth(); |
Oops, something went wrong.