2

I have searched high and low for an answer to this question but have been unable to find one.

I am building an Angular 2 app that I would like hosted on an S3 bucket. There will be an EC2 (possibly) backend but that's another story. Ideally, I would like to be able to check my code into Bitbucket, and by some magic that alludes me I would like S3, or EC2, or whatever to notice via a hook, for instance, that the source has changed. Of course the source would have to be built using webpack and the distributables deployed correctly.

Now this seems like a pretty straightforward request but I can find no solution exception something pertaining to WebDeploy which I shall investigate right now.

Any ideas anyone?

2 Answers 2

1

Good news, AWS Lambda created for you.

You need to create following scenario and code to achieve your requirement.

1-Create Lambda function, this function should do the following steps:

  • 1-1- Clone your latest code from GitHub or Bitbucket.

     1-2- install grunt or another builder for your angular app.
    
     1-3- install node modules.
    
     1-4- build your angular app.
    
     1-5- copy new build to your S3 bucket.
    
     1-6- Finish.
    

2-Create AWS API gateway with one resource and one method point to your Lambda function.

3-Goto your GitHub or Bitbucket settings and add webhook with your API gateway.

4-Enjoy life with AWS. ;)

Benefits: 1-You only charge when you have the new build.

2-Not need any machine or server (EC2).

3-You only maintain one function on Lambda.

for more info:

https://aws.amazon.com/lambda/

https://aws.amazon.com/api-gateway/

Sign up to request clarification or add additional context in comments.

Comments

0

S3 isn't going to listen for Git hooks and fetch, build and deploy your code. BitBucket isn't going to build and deploy your code to S3. What you need is a service that sits in-between BitBucket and S3 that is triggered by a Git hook, fetches from Git, builds, and then deploys your code to S3. You need to search for Continuous Integration/Continuous Deployment services which are designed to do this sort of thing.

AWS has CodePipeline. You could setup your own Jenkins or TeamCity server. Or you could look into a service like CodeShip. Those are just a few of the many services out there that could accomplish this task. I think any of these services will require a bit of scripting on your part in order to get them to perform the actual webpack and copy to S3.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.