Skip to content

Instantly share code, notes, and snippets.

@thomaspoignant
Created February 18, 2021 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaspoignant/d4ed6397f256ae087f7bddcd8f7fc7dc to your computer and use it in GitHub Desktop.
Save thomaspoignant/d4ed6397f256ae087f7bddcd8f7fc7dc to your computer and use it in GitHub Desktop.
/**
* buildAndInstallGOLambda build the code and create the lambda
* @param id - CDK id for this lambda
* @param lambdaPath - Location of the code
* @param handler - name of the handler to call for this lambda
*/
buildAndInstallGOLambda(id: string, lambdaPath: string, handler: string): lambda.Function {
const environment = {
CGO_ENABLED: '0',
GOOS: 'linux',
GOARCH: 'amd64',
};
return new lambda.Function(this, id, {
code: lambda.Code.fromAsset(lambdaPath, {
bundling: {
image: lambda.Runtime.GO_1_X.bundlingDockerImage,
user: "root",
environment,
command: [
'bash', '-c', [
'make vendor',
'make lambda-build',
].join(' && ')
]
},
}),
handler,
runtime: lambda.Runtime.GO_1_X,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment