Amiga500
Amiga500

Reputation: 6141

Deploying the code toe Lambda via Codeship

I need to somehow automate my Nodejs code deployment to Lambda. After looking at many alternatives (Serveless and others) and after talking to my team mates, we decided to use the Codeship for that. They already use it to connect to the Github, do the build there (npm i in my case). What we don't understand it, how to proceed after that step.

Upload it to S3, and somehow have Lambda pick it up? Or some other way of doing it?

Any insight is appreciated.

EDIT:

I was able to create Nodejs deployment to Lambda using Codeship fairly easy. I have followed these instructions. This is what I have under custom script:

pip install awscli
zip -r index.zip .
echo Zipping Done
aws lambda update-function-code --function-name "test_event_crm" --zip- 
file fileb://index.zip
echo update function is done
aws lambda get-function --function-name "test_event_crm"
echo lambda get function is done
aws lambda invoke --function-name test_event_crm --payload "$(cat 
data.json)” lambda_output.txt
echo **I dont end up here**
cat lambda_output.txt
echo **I also dont end up here**

The issue I face is the fact the code ends up from Github properly in the Lambda, but for some reason Build process never finishes. It just sits there, until it ends on its own (hours later). If you take a look at the echo command in the script, please notice that two last echo's are never executed. Build process keeps running.

What should I do to improve the script?

It seems that I need to send end command or something similar.

EDIT 2: I overlooked the script. There is an invoke function there, which I think I do not need. I have reworked the script, and it works now as expected. However, I am not sure is this the correct way of doing it. New script:

pip install awscli
zip -r index.zip .
echo Zipping Done
aws lambda update-function-code --function-name "test_event_crm" --zip- 
file fileb://index.zip
echo update function is done
aws lambda get-function --function-name "test_event_crm"
echo Get function is done
echo Deploy is done

Do I need aws lambda get-function ???

Upvotes: 0

Views: 95

Answers (1)

Michelle
Michelle

Reputation: 31

I'm from CodeShip support, glad to hear you decided to use our product! We do have two different products, CodeShip Basic and CodeShip Pro.

I typically recommend starting with Basic as it is simple to setup and you can start getting value almost instantly. Once you're a bit more familiar with the workflow - you can start a migration to Pro.

So more about Basic - you will connect to your repository using GitHub, GitLab, or BitBucket. Once connected, you will setup your build triggers which allows builds to start automatically when there are changes to your repository. When a build is triggered, CodeShip will spin up an Ubuntu Bionic build machine and check out your code for the given commit and run through your commands that are defined in the project settings. We have 3 seperate command blocks: setup commands, test commands, and deploy commands.

From what you've requested, I think you'll want to read through our AWS Lambda Deployment documentation. This is meant to be a starting place for you, so depending on your setup, it may not be as simple as plug-and-chug.

If you run into problems while setting up your project, please feel free to open a ticket with our support team and include the build URL where you are experiencing issues.

The last tip I'd like to point out is that CodeShip Basic has the option to SSH into a replica of a build machine - I highly advise that you take advantrage of this feature when setting up your project as it will allow you to try multiple commands without triggering a new build so you can more quickly get everything up and running!

I hope that helps and welcome to CodeShip! :)

Upvotes: 1

Related Questions