How to deploy django on AWS elastic beanstalk with postgresql - django

I tried a lot of tutorials including aws beanstalk official django deployment document. There is always some kind of error. eg:
none of my requirements.txt packages get installed on ec2. When i ssh to ec2 I see that Django==2.1.1 is not an available option that for installation.
Unable to connect to postgresql DB from ec2, but could connect from
my local machine, inspite of having added ec2 public IP4 to the
security group. It connects when I add ec2 security group ID to rds inbound though.
I spent many days trying to fix individual problem but still the overall attempt has been a frustrating failure. I know there must be lot of rookie aspiring django+AWS developers like me who would greatly appreciate a comprehensive tutorial that just works with python 3.6 instead of having to put pieces together or use third party services.
Thanks

Related

Hosting Elasticsearch on AWS: {"error":"You need to sign in or sign up before continuing."}

I am trying to host an Elasticsearch Application on an AWS Server. For this purpose I am using Elastic Enterprise Search. I configured the API connector as follows:
const connector = new AppSearchAPIConnector({
searchKey: "search-gs7t3micqu41z1dsou1ccz95",
engineName: "sentence-similarity",
endpointBase: "http://ec2-18-159-135-25.eu-central-1.compute.amazonaws.com:3002"
});
The application itself is running with npm under port 3000. I enabled both ports in the AWS Security Group.
After starting both Elastic Search and Enterprise Search, after npm start I can also connect to http://ec2-18-159-135-25.eu-central-1.compute.amazonaws.com:3000, so that works. However, once I make an API call over the application, I get the following error:
POST
http://ec2-18-159-135-25.eu-central-1.compute.amazonaws.com:3002/api/as/v1/engines/sentence-similarity/search.json
net::ERR_CONNECTION_REFUSED
Moreover, when I type curl http://localhost:3002/api/as/v1/engines/sentence-similarity/search.json in the console, I get the following error:
{"error":"You need to sign in or sign up before continuing."}
Therefore I assume, that there is a problem with the connection to Elasticsearch. When I was hosting the application on my local machine, I never encountered this problem.
My ideas, how to possibly fix the problem:
I had to reinstall Elastic Search and Enterprise Search on the AWS
Server. Possibly, something with the authentification went wrong, and
I cannot connect to my Elasticsearch engine.
There are two .yml files, one for Elastic Search and one for Enterprise Search, which I can configure. Possibly, I have to adjust these, when I host the application not on my local machine.
In any case, I am a beginner in deployment and I need some help for the details. Thank you very much in advance!
EDIT:
After some more research, I believe I identified the problem. It seems like on the AWS server, there is sort of a new Elastic Enterprise instance established. That means, that there is no engine configured yet, which is why the API call fails. How can I connect to my existing engine instead of having to create a new one?
Well I have not used the AWS Elastic search but i can give some suggestions, check below urls,
https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-vpc.html#kibana-test
https://www.youtube.com/watch?v=mWRo_JVgP_0
Also consider checking security groups.

Upload local Vagrant package.box to AWS

So, I've been working locally in a vagrant ubuntu box for the past month: I've spent a lot of time working on customizing it and installing exactly all the software I want on it. I started all of this through the normal vagrant tutorial (aka, nothing special). I packaged my local vagrant box into a package.box file. Now, I want to move my development environment (e.g. package.box file) to an Amazon EC2 instance on AWS. I know I'm not supposed to ask for software recommendations, but my question is basically: is this possible to do and, if it is, could you point me to some examples of people doing it? I've read that packer might be an option, but it looks to me (a very inexperienced perspective) that maybe I should have started with that instead of trying to use it now. Any help would be appreciated - I don't want to spend a couple weeks setting up a new environment when I have one locally set up.
Edit:
Progress! I followed #error2007s link and followed the tutorial. I'm at the point where I've uploaded the VMDK image to s3 and provisioned an instance using it (all done automatically with the ec2-import-instance command on the CLI). However, I don't see a Public IP to access the new instance after I start it up.
I think this is related to cloud-init somehow, but I'm not sure what that is really. I tried it with both the /etc/cloud/cloud.cfg file that came with the box as well as the one listed here and neither of the two boxes I uploaded gave me a Public IP to access.
Edit 2:
Here are some things I see in the Console (They all seem right to me, but a more experienced eye might see something wrong):
subnet info:
Auto-assign Public IP: yes
Network ACL:
VPC info:
DNS resolution: yes
DNS hostnames: yes
ClassicLink DNS Support: no
VPC CIDR: 172.31.0.0/16
DHCP Option Set:
Options: domain-name = ec2.internal domain-name-servers = AmazonProvidedDNS
From my perspective, those all look right, or am I missing something?
I assigned an Elastic IP per these instructions, but when I ssh ec2-user#<elastic-ip>, it says ssh: connect to host <elastic-ip> port 22: Connection refused. The security group assigned to the instance is set to allow all protocols on all ports. Also, this is the first time I encounter a Elastic IP and I'm unsure what exactly it is doing.
Amazon enables you to transfer your Vm to AWS as a EC2 instance. Check this tutorial this is more simple.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingVirtualMachinesinAmazonEC2.html
You want to use the Vagrant AWS provider found here:
https://github.com/mitchellh/vagrant-aws
This is a Vagrant 1.2+ plugin that adds an AWS provider to Vagrant,
allowing Vagrant to control and provision machines in EC2 and VPC.
This will allow you to provision your AWS instances using Vagrant, allowing you to migrate the same local development environment to an AWS EC2 instance.
There is a good tutorial here:
https://nurmrony.wordpress.com/2015/03/15/vagrant-deploy-and-provisioning-an-amazon-ec2-instance/
Hi I have found these articles but I have not yet tested them myself. Im still in the middle of organizing my personal notes and identifying my technology stack. I intend to have a Homestead vagrant box be replicated as an EC2 instance, so I wont have to configure the instance(s) manually.
https://nurmrony.wordpress.com/2015/03/15/vagrant-deploy-and-provisioning-an-amazon-ec2-instance/
https://www.tothenew.com/blog/using-vagrant-to-deploy-aws-ec2-instances/
https://foxutech.com/how-to-deploy-on-amazon-ec2-with-vagrant/
https://blog.scottlowe.org/2016/09/15/using-vagrant-with-aws/
https://devops.com/devops-primer-using-vagrant-with-aws/
I find their approaches similar. The only thing that I am worried at is the "vagrant add box" part.
I asked myselft, what if I had to do this setup again for familiarization purposes, what will happen since I already added a vagrant box (the dummy one, as instructed in the tutorials) previously.

Python app uses old filed on EC2 instance

I have an interesting problem:
There is an EC2 instance, on which py3env is stored
I deploy my web app from pyCharm to EC2 and run the server (runserver 0.0.0.0)
Since last week the web app uses OLD files, which I have already deleted from EC2. I check app files on EC2 - they are correct, but still I have 'old' app running.
Maybe there is some EC2 cache problem or what?
There is nice documentation about your question.

Setting up an Amazon Server with Go Daddy

I am trying to set up an Amazon Server to host a dynamic website I'm currently creating. I have the domain bought on GoDaddy.com, and I believe that what I've done so far has linked the domain to my Amazon account.
I followed this tutorial : http://www.mycowsworld.com/blog/2013/07/29/setting-up-a-godaddy-domain-name-with-amazon-web-services/
In short, this walked me through setting up and Amazon S3 (Simple Storage Service) and Amazon Route 53. I then configured the DNS Servers, and my website now launches properly on the domain.
I'm not sure on the next step from here, but I would like to set up:
-A database server
-Anything else that might be necessary to run a dynamic website.
I am very new to hosting websites, and semi-new to web development in general, so the more in depth the better.
Thanks a lot
You have two options on AWS. Run an EC2 server and setup your application or continue to use the AWS managed services like S3.
Flask apps can be hosted on Elastic Beanstalk and
your database can be hosted on RDS (Relational Database Service). Then the two can be integrated.
Otherwise, spin up your own t2.micro instance in EC2. Log in via ssh and set up the database server and application like you have locally. This server could also host the (currently S3 hosted) static files too.
I have no idea what your requirements are, personally I would start with setting up the EC2 instance and go from there as integrating AWS services is without knowing what you need is probably not the easiest first step.
Heroku might be another option. They host their services on AWS and give you an end to end solution for deploying and running your python code without getting your hands dirty setting up servers.

How to setup AWS elastic beanstalk with windows server 2012

I'm new to AWS setup, and after having put quite a lot of time into researching an easy way to setup an instance on AWS for a .NET application, I finally decided to go with Elastic Beanstalk.
After creating an elastic beanstalk application (sample application), I need to upload my files and DB to that application and access it via an URL.
I haven't found a simple straight forward tutorial showing this. If someone has links to tutorial websites or have got this done, would like you know the process.
I've created a security group and added a keypair. Do i need to access it via SSH and install FTP and so on?
Help is appreciated.
-Adi.
There are some tutorial videos on .NET development and AWS Elastic Beanstalk available from the Amazon Web Services site here:
https://aws.amazon.com/visualstudio/