Does your AWS Cloud9 deploy Lambda functions? No? Well, our Support Engineers are here to help you out.
At Bobcares, we receive similar queries all day long as a part of our AWS Support Services. Our Support Team is well-versed in coming up with solutions for each of them. Let’s find out how they helped with deploying Lambda functions via AWS Cloud9.
About AWS Cloud9 deploying Lambda functions
If you are looking for a way to add external libraries to a Lambda function developed via AWS Cloud9 you are in the right place.
- First, go to the AWS Cloud9 console.
- Then, open the AWS Cloud9 environment.
- Next, go to the left navigation pane and select Environment.
- In the Environment window, right-click the context menu for the function’s parent folder.
- After that, select the Open Terminal Here option to start a new terminal session.
- Then, run the following pip command in the terminal to import the external library module:
python -m pip install --target=./ ModuleName
Don’t forget to change ModuleName to the name of the module that has to be imported.
- Repeat the previous step for every module you want to import. Once you are done, you will notice the imported modules in the function’s parent folder.
Our Support Engineers would like to remind you that it is essential to have the correct version of the python Packages for these steps to work. You can verify this by specifying a requirements.txt file in the pip command for a trial run.
How to deploy Lambda function via AWS Toolkit?
You can also deploy serverless applications using the AWS toolkit with the following steps:
- First, open the AWS Explorer window and right-click the Lambda node, and choose Deploy SAM Application in the context menu.
- Then, select the template.yaml file. This will be used for deployment.
- After that, select the AWS Region you want to deploy the function to.
- Next, enter the name of the Amazon S3 bucket the deployment can utilize. Remember to ensure that the bucket is in the AWS Region you are deploying the function to. Another thing to look out for is to make sure that the Amazon S3 bucket name is globally unique among all currently existing bucket names.
- After that, verify that the serverless application includes a function that has a function with function type Image. Then we will enter an Amazon ECR repository’s name for the deployment to use. Remember to make sure that the repository is in the same region as the deployment.
- Next, enter the name of the deployed stack. It can be either an existing stack name or a new stack name.
- Finally, we will check whether we have successfully deployed a function on the AWS Toolkit. If there is an error, a similar message will pop up :
Error with child process: Unable to upload artifact HelloWorldFunction referenced by CodeUri parameter of HelloWorldFunction resource. S3 Bucket does not exist. Execute the command to create a new bucket aws s3 mb s3://pbart-my-sam-app-bucket An error occurred while deploying a SAM Application. Check the logs for more information by running the "View AWS Toolkit Logs" command from the Command Palette.
In the above example, the error is caused by the non-existing Amazon S3 bucket.
[Need help with another query? We are just a click away.]
Conclusion
In brief, we saw how easy it is to deploy Lambda functions using AWS Cloud9. Our efficient Support Techs also offered as a way to do this via the AWS toolkit, making things easier for us.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments