--- title: AWS Introduction tags: AWS --- # AWS Introduction ## Register an AWS account <iframe width="560" height="315" src="https://www.youtube.com/embed/oUoJBayrJT4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> ## AWS RDS -- Creating and connecting a PostgreSQL database with AWS RDS via pgAdmin :::danger If you get connection failed, please check whether you have set **inbound rules** and **outbound rules**!!! ::: * [AWS RDS](https://towardsdatascience.com/creating-and-connecting-a-postgresql-database-with-amazons-relational-database-service-rds-dcc9db0cd37f "Creating and connecting a PostgreSQL database with AWS RDS") ## AWS Elastic Beanstalk -- Deploy a web app, this service will automatically generate an instance on AWS EC2 for you ![](https://i.imgur.com/WHbfEV6.png) ### 1. Go to AWS Elastic Beanstalk page * Click on ==Services== * Click on ==Elastic Beanstalk== ### 2. Create a new environment ![](https://i.imgur.com/kz8GzGm.png) ### 3. Select environment tier ![](https://i.imgur.com/EIKUzlL.png) * Click on ==Web server environment== * Click on ==Select== ### 4. Enter your app information * Enter your app name * The environment name is auto-generated, so after filling in your app name, we can just scroll down to ==Platform== part ![](https://i.imgur.com/g7nOdin.png) * Choose ==Node.js== here as we prepared an app written in Node.js (a framework called Express) ![](https://i.imgur.com/CIE0gfY.png) * Scroll down to ==Application code== * [download the demo file here](https://drive.google.com/file/d/12s53bDon8eYmnBfeC--R0k5PJIcCLOkF/view?usp=sharing "download demo file") * Click on ==Choose file== and choose the demo file you have just downloaded ![](https://i.imgur.com/lJUQRym.png) * ==Version label==, here you can fill in an unique name for this version of codes you upload :::danger file **Maximum size** `512 MB` ::: * ==Configure more options==, here you can modify more detailed settings like load balancer, instances and much much more... We can just skip that and hit ==Create environment== ![](https://i.imgur.com/eM1cmOj.png) * As you see, it will really take a few minutes, so just be patient and wait ![](https://i.imgur.com/bSGvneB.png) ### 5. Now you can click on the link to see your app ![](https://i.imgur.com/APwm3i6.png) :::info When you don't provide a Procfile, Elastic Beanstalk runs npm start if you provide a **package.json** file. If you don't provide that either, Elastic Beanstalk looks for the file **app.js** or **server.js**, in this order, and runs it. ::: :::danger If the Health status is not **Ok**, you may click on **Configuration** on the left hand site, click on **Edit** of **Software**, scroll down to the bottom of the page, and you will see **Environment properties**, fill in ==port information==, then click on ==Apply==. Wait a few minutes, the app will restart. ::: ```Javascript=59 const PORT = process.env.PORT || 8081; app.listen(PORT, () => console.log('Server running on port ${PORT}')); ``` ![](https://i.imgur.com/E4Ph6U1.png) ## AWS Certificate Manager -- Get a SSL/TSL certificate and use it on an EC2 instance behind an ALB * When you click on the link, you will see this url is not secure, so we gonna get a SSL certificate ![](https://i.imgur.com/YozHOIK.png) ### 1. Apply a domain name #### 1.1 [Apply here](http://www.freenom.com/en/index.html "It's free and no credit card needed") :::info [More information in Chinese](https://zhuanlan.zhihu.com/p/109553641 "中文資訊") ::: #### 1.2 * Enter a domain name you would like to use * Hit ==Check Availability== to see if it's available * Hit ==Get it now!==, and it will become ==Selected== * Hit ==Checkout== ![](https://i.imgur.com/o8s5Mzj.png) #### 1.3 Go to AWS EC2 page to get some information * Click on ==Instances== on the left * Tick the name that you would like to see it's detail * Copy it's ==Public IPv4 address==, like **my IP** here is 18.181.219.41 ![](https://i.imgur.com/H0hpzuk.png) #### 1.4 Go back to freenom site * Paste your IP in these 2 columns * Remember to choose 12 months free (It's only 3 months by default) * Hit ==Continue== ![](https://i.imgur.com/tAOYvIN.png) #### 1.5 ![](https://i.imgur.com/MMHYhVY.png) * Tick I have read and agree to the Terms & conditins * Hit ==Complete Order== #### 1.6 Then you are good to go!! ![](https://i.imgur.com/OYvRUkv.png) * You can go to **Services -> My Domains** to check out all of your domains ![](https://i.imgur.com/9yEDCHe.png) ### 2. Search for Certificate Manager ![](https://i.imgur.com/IvfQoB7.png) ### 3. Click on ==Get started== under Provision certificates ![](https://i.imgur.com/FC7mtfR.png) ### 4. Click on ==Request a public certificate==, then click on ==Request a certificate== ![](https://i.imgur.com/YPIhdRz.png) ### 5. Fill the domain name we have just got from freenom * Then click on ==Next== ![](https://i.imgur.com/xy7a3hA.png) ![](https://i.imgur.com/DMXt71I.png) ### 6. Leave the default option as DNS validation * Just click on ==Next== ![](https://i.imgur.com/Xy2FaT1.png) ### 7. Click on ==Review== ![](https://i.imgur.com/E1lYHkS.png) ### 8. Click on ==Confirm and request== ![](https://i.imgur.com/aytdATL.png) ### 9. Pause here ![](https://i.imgur.com/a7XwyfT.png) ### 10. Go to AWS Route 53 page (open in a new tab) ![](https://i.imgur.com/JRTgSYE.png) * Click on ==Create hosted zone== ![](https://i.imgur.com/aHYbUY0.png) ### 11. Fill in domain name, and click on ==Create hosted zone== ![](https://i.imgur.com/8lYKR8E.png) ### 12. Click on ==Create record== ![](https://i.imgur.com/186o1NH.png) ### 13. Leave default setting, and click on ==Next== ![](https://i.imgur.com/0AD9jwk.png) ### 14. Click on ==Define simple record== ![](https://i.imgur.com/c5sDDAf.png) ### 15. Go back to AWS Certificate Manager page, we need to copy the name and the value below ![](https://i.imgur.com/eACokG5.png) ### 16. Paste here #### 16.1 The name from **15.** , remember to remove the last part of the url as it is repeated #### 16.2 Select ==IP address or another value depending onthe record type== #### 16.3 The value from **15.** #### 16.4 Select ==CNAME -- Routes traffic to another domain name and to some AWS resouces== #### 16.5 Click on ==Define simple record== ![](https://i.imgur.com/9jgR1d6.png) ### 17. Our record is successfully created!! ![](https://i.imgur.com/GRGm9i7.png) ### 18. Go back to step 9. and click on ==Continue== ![](https://i.imgur.com/qq4kRPF.png) ### 19. What? Pending validation!? ![](https://i.imgur.com/c51bqO4.png) --- ## Sources <iframe width="560" height="315" src="https://www.youtube.com/embed/ubCNZRNjhyo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/bWPTq8z1vFY" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/b0g-FJ5Zbb8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> [Chinese Source](https://medium.com/@chihsuan/aws-load-balance-%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5%E4%BB%8B%E7%B4%B9-33c30a59b596)