I'm working with AWS Lambdas and I deploy them using Serverless. Everytime I deploy any function I receive this kind of URL to hit the service:
https://mh6r122dq1.execute-api.us-east-1.amazonaws.com/{stage}/{function}
where 'stage' is either dev or qa, and 'function' is the name of my lambda function.
I'm trying to access to my lambdas using a more friendly URL. I followed this tutorial from AWS docs:
http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html
I can not make it work. I have already the certificates created, my company did it. So to me, this just needs to be as simple as select the name of your domain and attach it to your Lambda API gateway.
These are the steps I'm doing:
1) I create a Custom Domain Name here https://console.aws.amazon.com/apigateway/home?region=us-east-1#/custom-domain-names. The page offers me automatically the certificate. I'm using some made up name like my.service.com. I also tried using a fully qualified domain name from my company which is hosted in our AWS account. None of both worked.
2) Then from the same page I select the base path, the destination (which is my lambda) and the stage. After saving it, the page provides me with a value called 'Distribution Domain Name', it looks like abc123def456.cloudfront.com.
3) Then I go to Amazon 53 and I create a new Hosted Zone. Again, I'm sure here if I need something totally made up or a real domain. Then I create a new A record for a ip address, I mark Alias-true, and I put the value from above "Distribution Domain Name"
And that's it. Those are the steps I'm doing. Then when I tried to hit my Lambda, I followed the instructions from the page I put above in the section "Root URLs of APIs with default and custom domain names".
I followed this process a couple of times and I'm really wondering if that page is ok. When I hit my lambdas with the custom domain name I get a 404 or a "can not resolve this host".
Does anyone have followed that process from that page from AWS and had good results?
UPDATE Thu Jul 13 12:23
Here are some pictures of my settings:
I get "Could not resolve host" either for qa-lambda.lqwebservices.com
or rateloader.qa.lqwebservices.com
"Again, I'm sure here if I need something totally made up or a real domain" you need a real domain name. Also since you needed to create a new hosted zone, that means your company does not currently use AWS Route 53 for their DNS. You'll have to point something like api.company.com to abc123def456.cloudfront.com from whatever domain registrar your company uses.
Related
I am a new Full Stack Dev and I am already stuck with hosting my portfolio on AWS Amplify and using a domain that is through Google Domains. I am aware that using AWS is quite a bit of overkill for a simple portfolio but I would like to get the experience with AWS and I enjoy the challenge.
I've already accessed my DNS tab in my Google Domains page. According to AWS we need to create our two CNAME records. One for the domain and one for the ACM validation certificate. I have also created a synthetic record for the forward because Google Domains does not support ANAME/ALIAS records.
I've confirmed that the data that I've entered into the CNAME records were correct and that I've allowed time for the records to update yet in my Amplify portal it still shows that I need to configure my CNAME records.
Are there any thoughts on whether this could be a hiccup on the Google or the AWS end? Should I just give in and transfer my DNS to Amazon Route 53? Any thoughts would be appreciated, thank you!
AWS' recommended steps work, up until the forwarding part: https://docs.aws.amazon.com/amplify/latest/userguide/to-add-a-custom-domain-managed-by-google-domains.html
To correctly setup forwarding, do the following:
You have registered the address: myaddress.com
Go to the 'Website' tab under domains.google.com/registrar/myaddress.com
Click 'Add a forwarding address'
Edit the 'Forward from' section. This defaults to two entries: 'myaddress.com' and 'www.myaddress.com'. Remove the one beginning with 'www', in the other use the prefix '#' like so:
Enter 'www.myaddress.com' into the 'Forward to' field
Click 'Forward'. This will add two records, which should now be visible in the 'DNS' tab.
Following these steps should mean you don't get asked to delete the CNAME record you made in the steps provided by AWS (that points at cloudfront).
I am doing exactly what you are doing - if you were looking at Actions > View DNS Records, in the "Update DNS records" box. You may have missed the alert box with a link to View Docs - where the procedure for google is, are you referring to the configuration that i think is needed for other providers?
Where does it say you need to configure CNAME records? Is your site live?
I have an API gateway with a custom domain name (foo.mycompany.com).
foo.mycompany.com belongs to the production environment, i.e., there is traffic coming from the customers of the service almost every minute.
How can I migrate foo.mycompany.com to another AWS account without causing any downtime for the service?
When I create the foo.mycompany.com custom domain name in the AWS console of the new AWS account, I got The domain name you provided already exists. error.
Unfortunately it is not possible at the moment. I run a couple of API GW for high load clients and all had the same issue when migrating to new AWS accounts. We even reached to AWS specialists. The answer was :
Delete custom domain name in OLD account
Add custom domain in new account
This of course means downtime.
If someone else finds a blue-green migration possibility for these - I would like to know too.
This works perfectly if you move to different region.
The flow I used was
switch api domain to edge
create infrastructure in another region
switch DNS to that other region - custom domain was already created there.
Unfortunately, custom API domain has to be unique in a region.
I am in similar situation as you now and I am trying to figure out solution.
I have set up an S3 bucket to reroute all traffic to example.com to www.example.com with https according to this very poor AWS guide. It works for example.com and http://example.com.
But when I access https://example.com it hangs for a little while and then routes to a blank page. Why is it so difficult to redirect a URL I own to another one in AWS and how do I fix this?
Edit:
I am now configuring CloudFront distributions and trying to find one decent tutorial explaining how to perform this seemingly simple task.
Did you miss this line in the link you provided:
Note: The sites must use HTTP, because the redirect can't connect to Amazon S3 over HTTPS.
You are trying to do something that is expliciting called out as not being possible in the docs.
BTW: If you want to use https to service static s3 websites, using cloudfront if often the easiest and quickest way to do that.
https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-https-requests-s3/
So I finally figured this out and I am going to describe here what worked for me. E.J.'s answer above was a helpful pointer but wasn't specific enough to make this the absolutely trivial task I would hope this to be, even for a first-timer.
Here are the exact steps required, with some prior notes.
Two notes:
You HAVE to setup an SSL certificate with AWS to re-route after https. As an organisation AWS has not yet reached the place where automatic certificate management is... well... automatic. You have to use what I might call AWS "Extremely Manual" ACM.
You need an AWS S3 bucket (make it have the name of the domain your are routing FROM).
Steps:
Follow this guide to setup a S3 bucket that will route (without HTTPs) from example.com to www.example.com (or vice versa I guess)
Navigate to the absolute eye-sore that is Amazon CloudFront
Click everywhere until you find a button to "create distribution"
Set "Origin Domain Name" to the link for the bucket created in step 1. DO NOT use the one AWS recommends, you have to go to the bucket and copy the end-point manually, the one AWS fills-in automatically will not work. It should look like this: example.com.s3-website-eu-west-1.amazonaws.com but location and stuff will be different obviously. Not sure why AWS recommends the wrong end-point but that is the least of my concerns about this process.
This guide works for the rest of the CloudFront distribution creation but is not super specific and points to this mess at one important part. The other steps are okay but when creating an SSL certificate just click that "Request or Import a Certificate with ACM" button (you will have to refresh after creating a certificate because Ajax didn't exist when the AWS console was made 200 years ago)
And the most important step, take the link or whatever it is to your CloudFront distribution (which will look like this: d328r8fyg.cloudfront.net, this one is fake because apparently you're not supposed to share them), and make the A record for example.com created in step 1 point to that CF distro instead of pointing directly to your bucket.
And voila, only took about 3 hours to get a URL to redirect somewhere securely. Not sure why people expect us to make it to Mars when the largest company in the world can't point one url to another and Microsoft Image Editor still can't crop to a specific pixel dimension.
Anyway. I'm glad this is over.
I have example-bulkorder.com domain which is connected to ecommerce hosting (Business Catalyst).
This site doesn't need ecommerce anymore so I create a simple page on example.com/bulkorder which has a form that send email to me so that I can handle bulk orders manually via email.
At the moment I just set up redirection with javascript but when I unsubscribe Business Catalyst hosting, I will need to find a way to set up this redirection from example-bulkorder.com domain to example.com/bulkorder
Is there a way to do this with AWS or should I just kill the old domain?
I am not worried about all pages under the domain but at least the main url to be redirected.
Or should I just let the old domain goes to broken link and let people to find out that the url is not available? What's the best solution? I want to keep the old domain in case I need it with separate ecommerce system in the future.
Use the following procedure to redirect your domain
Requirements
A hosted zone for the domain example-bulkorder.com is hosted in Amazon Route 53.
You have permissions to add resource records to the hosted zone of example.com.
You have permissions to create an Amazon S3 bucket.
You are able to create an S3 bucket with the exact name for example.com.
Note: The sites must be HTTP because the redirect cannot connect to S3 over HTTPS.
In the Amazon S3 console, create an S3 bucket with the exact name as example-bulkorder.com.
Note: S3 bucket names must be globally unique. If the bucket name you need is already in use, this solution cannot be used.
Select the bucket you just created, and then choose Properties. Expand the Static Website Hosting drop-down menu, and then choose Redirect all requests to another hostname.
In the Redirect, all requests to another hostname field, enter example.com/bulkorder and then choose Save.
In the Route 53 console, select the hosted zone named example-bulkorder.com.
Create a resource record for example.com with the following values:
Record Type: Choose A IPv4 address.
Alias: Choose Yes.
Alias Target: Select the blank value field, expand the drop-down menu, and then choose your S3 bucket under the heading S3 Website Endpoints.
Routing Policy: Choose Simple.
Evaluate Health Target: Choose No and then choose to Create.
Note: The drop-down menu might take a few moments to populate your bucket name.
You should now be able to redirect example-bulkorder.com to example.com/bulkorder.
You could do this serverless by using Cloudflare (probably the easiest way), just need to create a page rule to redirect your domain to your desired endpoint.
Check this post: How do I perform URL forwarding or redirects with Cloudflare?
Within AWS is also possible you have more options, one of this is using an S3 bucket, check this article: https://aws.amazon.com/premiumsupport/knowledge-center/redirect-domain-route-53/
This is another problem I am having, here is the info.
My endpoint for the first bucket works, but not the 2nd bucket, and using my domain name in the browser just doesn't work at all.
Once again I have taken screenshots, this is driving me insane, I have no idea how to correct it, it just doesn't find my root or something.
Record Sets
Buckets
I can't post more than 2 links
If anyone can help me, even PM me, I'll give my login details to take a look, because I'm completely stumped.
You should follow the directions on Setting Up a Static Website Using a Custom Domain.
For the first bucket, the steps are:
Create an Amazon S3 bucket with the same name as your domain (justdiditonlne.com)
Add a bucket policy to make the content public, or modify desired objects to make them publicly accessible
Turn on Static Website Hosting, and you will receive a URL like: justdiditonline.com.s3.amazonaws.com
Create a Route 53 entry for justdiditonline.com, type A, set Alias=Yes and enter the static website hosting URL
For the second bucket:
Create an Amazon S3 Bucket with the desired domain name (www.justdiditonline.com)
Turn on Static Website Hosting, but this time select Redirect all requests to another host name. Enter www.justdiditonline.com.