Deploying a war to Elastic Beanstalk with Pallet - amazon-web-services

I've got a Java servlet packaged in a war, and need to deploy it to Elastic Beanstalk. I can roll my own deployment script using Amazonica, but I'd rather leverage Pallet for this.
A Google search for "pallet elastic beanstalk" is not turning up anything useful, other than a "How to deploy a clojure web application to Amazon EC2" question on Stack Overflow. The answer looks quite promising, but it doesn't cover setting environment properties, and I'm not sure whether that group spec would create an Elastic Beanstalk environment or a regular EC2 one with Tomcat.
Has anyone done this? Is there a nice blog post or recipe for it?
Just to be clear, the war itself is not a Clojure app, it is just a war built with Maven from a Java project somewhere.

Since this is not an action that happens to an instance, for instance it does not change a member of a pallet group, I would recommend using clj-action to upload it using amazonica at the appropriate place in the phase.
I'm assuming that some instance (or group) you are deploying with pallet needs this web service to be in place so it can be configured to connect to it. In cases like this it would make sense to define a phase which uploads the war file and saves its configuration into the session. Then later phases on any instance in the deployment can see where the web service is available.
If it's only needed by one instance/group then it's fine to simply call amazonica (through clj-action) in the middle of the configure phase and then configure that instance to use the web service in the same plan-fn.

Related

How to choose between AWS Elastic Beanstalk and App Runner services?

Similarities that I see are:
They are PaaS offerings.
They make AWS more similar to Heroku.
They abstract away load balancing and auto scaling stuff.
The only difference that I see is that App Runner uses docker but Elastic beanstalk may not use it. Correct me if I am wrong, but seems like it is not a requirement to containerize your app first to be able to use it on App Runner as you can just supply the Github Url and App Runner will containerize it for you.
So what is the difference between the two and how do I make a decision to choose one over the other?
It depends. AWS App Runner (AR) is container based only. Not every application nor developer want to use containers, nor their application is suited for container deployments. AR also gives you very little control over your resources and operating system. Many application may require such control (e.g. gpu) Also AWS EB gives you much more control over your resources, including operating system.
As Cloud Guru said that
Behind the scenes, the core of App Builder is that it builds an Amazon
ECS Cluster and uses Fargate to execute your containers
So as you can see
Elastic Beanstalk belonging to PaaS
App Runner is serverless belonging to FaaS
Furthermore, App runner just works with Container only. So it really depends on what kind of your app is.

Spring boot/cloud microservices on AWS

I have created a Spring cloud microservices based application with netflix APIs (Eureka, config, zuul etc). can some one explain me how to deploy that on AWS? I am very new to AWS. I have to deploy development instance of my application.
Do I need to integrate docker before that or I can go ahead without docker as well.
As long as your application is self-contained and you have externalised your configurations, you should not have any issue.
Go through this link which discusses what it takes to deploy an App to Cloud Beyond 15 factor
Use AWS BeanStalk to deploy and Manage your application. Dockerizing your app is not a predicament inorder to deploy your app to AWS.
If you use an EC2 instance then it's configuration is no different to what you do on your local machine/server. It's just a virtual machine. No need to dockerize or anything like that. And if you're new to AWS, I'd rather suggest to to just that. Once you get your head around, you can explore other options.
For example, AWS Beanstalk seems like a popular option. It provides a very secure and reliable configuration out of the box with no effort on your part. And yes, it does use docker under the hood, but you won't need to deal with it directly unless you choose to. Well, at least in most common cases. It supports few different ways of deployment which amazon calls "Application Environments". See here for details. Just choose the one you like and follow instructions. I'd like to warn you though that whilst Beanstalk is usually easier then EC2 to setup and use when dealing with a typical web application, your mileage might vary depending on your application's actual needs.
Amazon Elastic container Service / Elastic Kubernetes Service is also a good option to look into.
These services depend on the Docker Images of your application. Auto Scaling, Availability cross region replication will be taken care by the Cloud provider.
Hope this helps.

Spring Boot microservice deployment in Docker

I need to develop a Spring Boot microservice and need to deploy in Docker. Now I developed a sample microservice. When I am learning Docker and container deployment I found many documentations for installing Docker and building images and running the application as container packaging. Here I have some doubts in deployment procedure:
If I need to deploy 4 Spring Boot microservice in Docker, do I need to create separate image for all? Or can I use the same Docker file in all my Spring Boot microservices?
I am using PostgreSQL database. So can I include that connection into Docker image file? Or I need to manage separately?
If you have four different Spring Boot applications, I suggest creating four different Dockerfiles, and building four different images from those files. Basically put one Dockerfile in each Spring application folder.
You can build PostgreSQL credentials (hostname, username & password) into the application by writing it in the code. This is easiest.
If you use AWS and ECS (Elastic Container Service) or EC2 to run your Docker containers you could store the credentials in the EC2 Parameter Store, and have your application fetch them at startup, however this takes a bit more AWS knowledge and you have to use the AWS SDK to fetch the credentials from the application. Here is a StackOverflow question about exactly this: Accessing AWS parameter store values with custom KMS key
Ask Question
There can be one single image for your all micro-services but its not a good design and not suggested. Always try to decoupled the things one from another. In your case, create separate images(separate Dockerfile) for each micro-service.
Again same thing for your second question, create a separate image(one Dockerfile) for your database as well. And for the credentials, you can follow the Jonatan's suggestion.

AWS Elastic Beanstalk - Using Mongodb instead of RDS using Python and Django environment

I've been following the official Amazon documentation on deplaying to the Elastic Bean Stalk.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python.html
and the customization environment
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html#customize-containers-format
however, I am stuck. I do not want to use the built in RDS database I want to use mongodb but have my django/python application scale as a RESTful frontend or rather API endpoint for my users.
Currently I am running one EC2 instance to test out my django application.
Some problems that I have with the Elastic Bean:
1. I cannot figure out how to run commands such as
pip install git+https://github.com/django-nonrel/django#nonrel-1.5
Since I cannot install the device mongo driver for use by django I cannot run my mongodb commands.
I was wondering if I am just skipping over some concepts or just not understanding how deploying on the beanstalk works. I can see that beanstalk just launches EC2 instances and possibly need to write custom scripts or something I don't know.
I've searched around but I don't exactly know what to ask in regards to this. Top results of google are always Amazon documents which are less than helpful in customization outside of their RDS environment. I know that Django traditionally uses RDS environments but again I don't want to use those as they are not flexible enough for the web application I am writing.
You can create a customize AMI to your specific needs the steps are outline in the AWS documentation below. Basically you would create a custom AMI with the packages needed to host your application and then update the Beanstalk config to use your customize AMI.
Using Custom AMIs

Amazon Elastic BeanStalk, WAR Files, Hot Reloading

I love the simplicity of Amazon Elastic Beanstalk.
However it seems rather difficult to hot-reload code. In particular, in reading about the WAR file format (Sun), it states:
One disadvantage of web deployment using WAR files in very dynamic
environments is that minor changes cannot be made during runtime. Any
change whatsoever requires regenerating and redeploying the entire WAR
file.
This is bad. I like to program in Clojure, which involves lots of testing / code reloading.
My question: what is the right way to to hot code reloading in Amazon Elastic Beanstalk?
Thanks!
Do your development on a local instance of Tomcat, an IDE like IntelliJ will automatically update your changes. Once you have reached a reasonable milestone, e.g. completed a story, then redeploy your war.
I ended up giving the Amazon Elastic Beanstalk route, and just ended up setting EC2 instances.
The tomcat installation on the ami's created via elastic beanstalk have hot reload turned off. #Rob's answer would be the way to go. I'm not sure why you'd want to do it any other way, to be honest.