Created
February 18, 2021 14:03
-
-
Save thomaspoignant/d4ed6397f256ae087f7bddcd8f7fc7dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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