AWS CLI

Mac Installation

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html

S3

https://stackoverflow.com/questions/41032069/use-current-working-directory-as-path-with-aws-cli

  • Sync current folder to a bucket: aws s3 sync . s3://[bucket-name]

  • You can also sync current folder to a bucket’s sub-folder. Please refer to the link.

Route 53 and CloudFront

Today I found my CloudFront respond 403 error.

This is the steps I debug the issue: Step 1: ```shell script dig something.example.com # This is helpful for debug network. Better than ping or netstat. something.example.com. 299 IN CNAME ja726pnjlery77.cloudfront.net. ja726pnjlery77.cloudfront.net. 59 IN A 13.224.164.14 ja726pnjlery77.cloudfront.net. 59 IN A 13.224.164.115 ja726pnjlery77.cloudfront.net. 59 IN A 13.224.164.34 ja726pnjlery77.cloudfront.net. 59 IN A 13.224.164.5


Step 2:
Open http://ondemand.simplyhired-qa.com/ in Chrome.

Then right click and click `Inspect -> Network`.

Then refresh page and click the `something.example.com` in Name.

Pay attention to the `Remote Address: 127.0.0.1:1087` in `Headers`.

Here `127.0.0.1:1087` is my browser's proxy. So I need to close the Proxy. 

Then refresh again. I found `99.84.199.33` which is not in the list I got in step 1.

So I switch to another Wifi and refresh again. I got the IP which is listed in the step 1.

# RDS
## How to do SQL performance analyzing?
* AWS has a feature called [performance-insights](https://aws.amazon.com/rds/performance-insights/).

## Others
* [How to dump database to local from RDS](https://gist.github.com/syafiqfaiz/5273cd41df6f08fdedeb96e12af70e3b).
You need to [create database](https://www.postgresql.org/docs/9.0/sql-createdatabase.html) before importing.
```shell
psql -d overwatch_qa -f overwatch_qa_20201218.sql

If you have created the overwatch_qa locally before, you can rename it by:

psql -h localhost -p 5432 --username postgres
ALTER DATABASE example_db RENAME TO example_db_new_name;

ElasticBeanstalk

Deploy Rails 6 project

  • The App folder is under /var/app/current or /var/app/staging.
  • There is a AWS S3 bucket for your account’s ElasticBeanstalk. If you don’t like EB automatically rollback to a previous version, simply remove the related app_timestamp.zip would be good.
  • I got a error:
    Missing rackup file 'config.ru'
    /opt/rubies/ruby-3.0.6/lib/ruby/gems/3.0.0/gems/puma-6.4.2/lib/puma/configuration.rb:366:in `load_rackup'
    

To solve it, you should read https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby.container.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ruby-platform-procfile.html