I created a Django Rest APIS using the Django Rest framework.
I used Zappa to deploy my DJANGO API and got a working URL
https://autocreatedname.execute-api.region.amazonaws.com/dev
Zappa created an s3 bucket and a lambda function
After that, I created a Cloudfront distribution with my custom domain name and got
d3b779m4oksdfs.cloudfront.net --> this works in isolation on the browser.
I created AWS certification and added CNAME and Value to my Godaddy DNS and it's active and validated.
Now, I am not sure if I need Amazon route 53/API Gateway to connect these.
Related
I have a react app hosted on s3 bucket and a Django rest api hosted on elastic beanstalk. The problem comes when I go to my bucket website endpoint and inspect network urls. I realize that the request endpoint is not the one defined in my react app (api url) but it's the bucket website endpoint. I would appreciate any help. Thanks!!
I have a custom domain setup in route53 and using rout53 as domain service provider. I have a static page hosted in aws s3 bucket which I am using as the home page of the site. In route53 I have mapped the aws s3 url to my custom domain by adding alias records as per this document.
I also have some lambda functions, which serves html pages on requests. Now I am trying to map the api endpoint of these lambda functions to my custom domain.
The flow is mainly like this, when the user hits the home website i.e. xyz.com, the homepage is served from the s3 static site. When the user navigates to other page say xyz.com/products/productId, the html is served from the lambda function. I am able to follow and do most of the steps for mapping api gateway endpoint to custom domain, but it's at adding DNS records I am facing the issue and getting the error A record with specified name already exists, which is understandable as I have already added the A record for routing to s3 bucket for my root domain.
My question is, can I add multiple records for the same type A in aws? Or is there other way to approach this problem?
No, you can't do it this way. A DNS name can only resolve to one thing.
Instead, you could create a subdomain so that:
xyz.com --> Amazon S3 bucket
products.xyz.com --> API Gateway
You could pass the productId as a parameter (eg products.xyz.com/?productId=42).
I'm not very familiar with deployment and networking as I'm primarily a frontend developer. I want to create a project with Laravel and React (separated, not integrated with blade), and deploy them to AWS. I want to use Laravel only as an API server, and I'm planning to deploy it on EC2. If I host my React app on S3, how will it be possible for me to share the same domain with the API sever running on the EC2 instance?
I know that I can have separate subdomains,like www.example.com for my React app and api.example.com for my API server. However, if I want to have www.example.com for my React app and www.example.com/api for my API server, what options do I have? And what resources can you recommend for me to get more up to speed on this topic? Thanks!
As you want to use S3 and EC2 you would need to use a service that can distribute to both endpoints based on a condition.
The best service for this would be CloudFront, which supports distribution to S3 and EC2 (as a custom origin).
To do this you would create your distribution with an origin for the S3 bucket, and an origin for the API. As your API is hosted on the /api/* path you would add this as the path pattern when adding the secondary origin via a behaviour.
CloudFront will then route any requests to /api/* paths to your EC2 origin.
I have found an article named How to route to multiple origins with CloudFront which I hope will explain the steps to accomplish this in greater detail.
I need to set an Amazon Domain as a custom domain for a Heroku app. I found the next tutorial https://devcenter.heroku.com/articles/route-53 but it doesn't work if the app needs https requests. The first idea was to set up the SSL Certificate in Heroku, but the SSL Amazon Domain manager doesn't allow to download the certificate, so the SSL need to be managed by AWS.
What is the best way to add Amazon SSL to a Heroku app?
The best option I found was to create an AWS CloudFront and configure it like Karan describes in his answer but with some add-ons:
Create a certificate from AWS Certificate Manager and approve it.
Create a CloudFront distribution with the Origin Domain Name as your Heroku URL such as myapp.herokuapp.com and the custom SSL certificate as the one you created from the AWS Cert Manager.
While creating the distribution, make sure that you have the TTL as 0, else all the responses will be cached
If you don't complete this step probably you will get an error like this:
This distribution is not configured to allow the HTTP request method that was used for the request. The distribution supports only cachable requests.
Follow the guide I mention in the question [https://devcenter.heroku.com/articles/route-53][4]
Amazon created SSL certificates only work with supported Amazon services such as Elastic Load Balancers, CloudFront distributions and API Gateway.
The easiest method to use Amazon SSL certificates is to add a load balancer. Another method is to enable CloudFront.
AWS Certificate Manager
I have an Django+Postgres app that has a multi-tenant structure and I don't have prior experience deploying this type of app to AWS. I have followed the general Elastic Beanstalk tutorial to deploy a simple app. (https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/) However, I am looking for a solution that allows me to more flexibly create different "sites". Currently, I have learned to create different sites via this tutorial (http://mycodesmells.com/post/django-tutorial-multi-tenant-setup).
So i have below questions :
how to deploy this app (I am leaning toward not using Elastic Beanstalk but just deploying it to EC2)
how I could create different sites after deploying this app.
The following should help:
Set up your .ebextensions so your Django project deploys with eb deploy.
Set up django-storages with AWS S3 for mediafiles if you need to.
Purchase a domain and set it up with AWS Route 53 (you can buy via Route 53, too).
Point your root domain alias to your Elastic Beanstalk app.
Point a wildcard domain to your app, too.
Set up AWS SES to save your domain emails to an AWS S3 bucket. You can use other providers as well, SES is just about the easiest.
Provision AWS ACM certificates for HTTPS support.
You now have your site working under .example.com and can use tenant.example.com to refer to a single client's setup - it refers to the same deployment but has a different Host header which lets Django tenant schemas to distinguish clients. You have wildcard forwards and do not need any setup other than in Django for adding new tenants.