Custom Runtime bootstrap script inline?

0

When you use the Amazon Linux 2 custom runtime with Lambda, is there a way to include the bootstrap.sh inline with a CloudFormation template? I want to just use the default provided bootstrap.sh that automatically comes as the entrypoint when you create an AL2 Lambda in the console.

I guess another way of asking is: is there a way of having multiple files when you're using the inline/ZipFile approach of including code for your Lambda? And in particular, is there no way to just say something like default or reference an AWS-hosted GitHub repo for the bootstrap, since it is default.

AWS
asked 2 years ago334 views
1 Answer
2
Accepted Answer

If you are using a custom runtime with Lambda, you need to upload the bootstrap file as part of the code package. There is not a way to grab an external bootstrap file. All Lambda code needs to be self-contained within the zip file. You can just add the bootstrap file to your code .zip archive. However, it may be simpler to split apart your code artifact and the custom runtime by using a Lambda Layer. You create a Lambda layer, which is just another zip archive, and then attach it to one or many Lambda functions. You can see the layer example in the doc you shared. https://docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html#runtimes-walkthrough-function. In Cloudformation, you can only specify the function code inline for Node.js and Python. Have you looked at AWS SAM, this is a handy transform for CloudFormation which makes it much easier to package up layers and functions? It builds the zip files and uploads them; you don't need to manage S3 buckets. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/building-layers.html

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions