How to access beanstalk environment URL from EC2 - amazon-ec2

My web application deployed via Elastic Beanstalk also reads from an SQS queue. As part of my blue/green deployment approach, I'd prefer only the environment actively serving production HTTP requests to pull messages from the queue. My original thought is to have the app periodically check the URL of the Elastic Beanstalk environment into which it is deployed and only read from SQS if the URL matches a certain pattern (indicating it is the current "production" environment).
How, from an app running on an Elastic Beanstalk deployed EC2 instance, can I determine its environment URL? (Or is there a better way to accomplish this goal?)

A better approach would be to look for an environment variable that you can control via the Elastic Beanstalk console. If the value of your environment variable is something like "production", your app should do production-y things.

Related

Deploy a ASP.NET website in AWS

I have to deploy my .NET web application in AWS. I am very new to AWS and I have very little time to complete this task.
Please help me by providing me some steps to be followed or any tutorials.
It is really easy. This can be done via AWS Elastic BeanStalk.
It very very simple and can be done in minutes.
You can follow the steps here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_NET.quickstart.html
This should be helpful too: https://www.youtube.com/watch?v=z-N0z5K_WFI&t=606s
AWS Elastic BeanStalk is free but the EC2 instances running will incur charge. When setting up the application in Elastic BeanStalk console in AWS, choose single instance rather than load balanced/autoscaled etc. if it is not a production application.
Let me know if you get stuck anywhere.

Preserve content after elastic beanstalk deployment

I have a Symfony2 website running on Amazon EC2 and Elastic Beanstalk. Each time I deploy a git version of my project immediately lost the contents of a folder ("/web/uploads")
Is there a way to tell to Elastic Beanstalk that this content shouldn´t be overriden?
I was thinking on specify an extra command on container_commands parameter inside my .ebextention file but I´m not sure it is the best way to resolve the problem.
You can't preserve that content. You will need to store it externally in a location such as S3, RDS, DynamoDB, etc. The other thing about Elastic Beanstalk to note is that if it scales up another instance of your app it won't have the content you stored locally and won't have access to it. I know it sounds harsh and limiting, but having an automated config/deploy is less trouble in the long run, IMHO. ;)

Running multiple environments on one AWS EC2 instance (Elastic Beanstalk)

I am very new to the Amazon AWS services. I was wondering if there is a way to run an instance of EC2 (say, Amazon Linux AMI) and then connect two environments to this instance.
Particularly, I'd like to run a PHP and a Tomcat environment on a single EC2 instance.
The problem is, every time I create a new environment in Elastic Beanstalk, it seems to create a new EC2 instance as well. Am I missing something here?
I'd appreciate any hint on this.
AWS Elastic Beanstalk is designed for deploying your running apps in a way that is designed for scalability from the ground-up. Because of this, Elastic Beanstalk will launch one or more EC2 instances, connect them to an Elastic Load Balancer instance, configure CloudWatch monitoring and Auto Scaling triggers.
Also, because of its fundamental design for scalability, Elastic Beanstalk is designed around a one-app-per-environment model (whereby "environment", I mean one of these EC2 + ELB + CloudWatch + AutoScaling clusters).
Since running two separate web servers with two separate apps (PHP & Java) is not a fundamentally scalable design, it's not a use-case that Elastic Beanstalk is optimized for.
You are free to spin-up a standalone EC2 instance and install whatever you'd like on it, but you're right — git aws.push support has not been made available for standalone EC2 instances. If the git support is important to you, you'll need to weigh the pros and cons of each approach.
I would also like to be able to do this, basically from a cost perspective for demos etc.
For example, a single instance with one PHP app and one Java app. Or, a single instance with two Java apps.
However, from what I have read so far in the Elastic Beanstalk developer guide, I have not found anything explicitly stating that multiple applications per environment is supported (or even, multiple environments per EC2 instance - if that even makes sense).
It makes me wonder if this is a feature that is often requested and planned for the future, or alternatively if the single-app-per-environment model is 'by design' for some reason.

amazon EC2 load balanced - how to deploy web app?

We're looking to move to amazon cloud using EC2 and RDS.
I'm looking at load balancing, which I would like to do, two servers, each in a different availability zone to protect against downtime.
My question is how to deploy web applications and updates to them? I assume there is a better way than individually updating the files on each EC2 server?
In systems past, I have used the vcs puppet module to ensure that the appropriate source code is installed on my system, in addition to using puppet to build the configuration files for the apache/nginx server that I'm using. Another possibility is to push your application in a deployable state (if you're not using a scripting language) to Amazon S3, and have your run-time scripts pull the latest build from your S3 bucket.

Should I use a regular server instead of AWS?

Reading about and using the Amazon Web Services, I'm not really able to grasp how to use it correctly. Sorry about the long question:
I have a EC2 instance which mostly does the work of a web server (apache for file sharing and Tomcat with Play Framework for the web app). As it's a web server, the instance is running 24/7.
It just came to my attention that the data on the EC2 instance is non persistent. This means I lose my database and files if it's stopped. But I guess it also means my server settings and installed applications are lost as they are just files in the same way as the other data.
This means that I will either have to rewrite the whole app to use amazon CloudDB or write some code which stores the db on S3 and make my own AMI with the correct applications installed and configured. Or can this be quick-fixed by using EBS somehow?
My question is 1. is my understanding of aws is correct? and 2. is it's worth it? It could be a possibility to just set up a regular dedicated server where everything is persistent, as you would expect. Would love to have the scaleability of aws though..
If you use an EBS volume with your EC2 instance, you can mount/dismount them to have persistent storage. You can also use Amazon RDS to handle your database too which is handy (but can be slightly on the pricier side.)
So a way to think of it is:
Your EC2 instance: Get the OS set up exactly like you'd like it along with your web application - basically, get your static stuff all in place.
EBS volume: That can be mounted and can be used for things like user uploads.
RDS instance: This is a dedicated database server with no hassles. It's nice - I use a MySQL RDS and it automatically makes two daily backups, and is scalable like EC2 instances.
Amazon Web Service is a better approach at hosting your applications Jon. You have a basic understand of AWS but you need to know that you can also launch an instance that is persistent. Just launch an instance of a persistence AMI. Also you can install you database,webs server on the instance like a regular server. There is probably just minimal differences from running an Ec2 instance and a dedicated server. If you have any other questions you can contact me.

Resources