跳到主要內容

why create at least two subnets in different AZs is a must have practice?

今天遇到了一個有趣的問題,在 AWS VPC 裡要 create RDS DB instance 遇到了一個無解的問題。

原本的 VPC 規劃時只有兩個 subnet,而且無法再加進其他 subnet。

VPC CIDR: 192.168.1.0/24
Subnet 1 CIDR: 192.168.1.0/25
Subnet 2 CIDR: 192.168.1.128/25

更悲劇的是,這兩個 subnet 都是屬於同一個 Availability Zone (AZ).....

雖然在 VPC 裡 create RDS instance 時可以選擇 "Multiple AZ deployment = No" 但接下來卻還是一定要 create DB subnet group.

而 DB subnet group 則是至少要有兩個 subnet 要在不同的 AZ,
我原本以為如果我選擇只要 single AZ deployment,那 create DB subnet group 應該就不是必要的,但看起來 AWS 是不允許的。去翻了一下 Working with an Amazon RDS DB Instance in a VPC 第一條真的寫了
"Your VPC must have at least one subnet in at least two of the Availability Zones in the region where you want to deploy your DB instance. A subnet is a segment of a VPC's IP address range that you can specify and that lets you group instances based on your security and operational needs."

雖然我不知道怎麼只有一個 subnet 但是可以有兩個 AZ,但就我的理解應該就是指,你的 VPC 下要有兩個以上的 subnet,然後至少有兩個 subnet 是屬於不同 AZ。

這個故事告訴我們:

  • 創建 VPC 時,可大,不可以小。雖然目前只有兩個 subnet 可以用,但是可以留一些空間讓以後還有機會加 subnet 進去。
  • VPC 裡的 subnet 最好手動指定在不同的 AZ。
不然要砍掉 VPC 或者 subnet 重建會是很麻煩的一件事...

留言

這個網誌中的熱門文章

3M UVA3000 更換濾芯紫外線燈匣

用了一年的3M濾水器提示說要換濾芯和燈匣 上 Youtube 想找教學的影片可是沒看到 UVA 3000 的 經過了一番奮戰後在這邊記錄一下 希望可以幫助後人,以免再重蹈覆轍。 Step 1. 拔掉插頭,把淨水器從牆上拿下來(基本上他是掛著而已),比較方便施工。 Step 2. 把前蓋往上拉,很容易就可以看到裡面的東西了。 Step 3. 打開後可以看到有兩個柱狀體,左邊的是燈匣,右邊的是濾芯。 Step 4. 這裡有個祕技是,這兩個柱狀體是可以往上 翻開30 度左右,這樣就可以有比較大的空間施工。 Step 4. 更換濾芯的話,柱狀體的瓶身上有箭頭,往左就是轉開,往右就是鎖緊。 Step 5. 更換燈匣的話比較麻煩一點,因為他底部是電源,頂部的右邊有個突出來的小方塊。對照淨水器上方連接處的話會有個弧形的凹槽,這是要 match 的.如果你只注意瓶身的箭頭往右鎖回去,就會造成漏水...Orz... Step 6. 把前蓋蓋回,機器掛回牆上,插插頭,開水,如果機器沒有告訴你有燈匣異常或漏水的話,就可以長按 C / UV  Reset 計數器了. 所以關鍵字就是,要往上翻 30 度,燈匣上面的小凸點要在右側,要看瓶身的 小箭頭. May it helps!

AWS CloudWatch Synthetics

原本想用 DataDog 的 Sythetics API Test 做 e2e monitoring & alarm 但是遇到 multi-part form-data 沒辦法在 Request Body 使用 \r\n 的問題 curl -i -X  --trace-ascii - -F 'key=key1' -F 'key2=key2' https://whatever.totest.com/auth 你可以看到送出的 Content-Length 和 Request Body 是 Content-Length: YYY Content-Type: multipart/form-data; boundary=xxxx --xxxx Content-Disposition: form-data; name="key1" key1 --xxxx Content-Disposition: form-data; name="key2" key2 --xxxx-- 但是使用 DataDog 送出去的話只會用 \n 和 curl 送出的一比較,就發現 Content-Length 比較小,但是 DataDog 似乎沒辦法改.. 試了一下 AWS CloudWatch Synthetics Canary 發現他其實就是 deploy 一個 nodejs lambda layer 裡面執行 Puppeteer, Chromium 和 AWS SDK 但是又整合了 cloudwatch dashoboard, cloudwatch logs 和 cloudwatch alarm,所以不只可以跑 script 還可以透過 chromium 去抓網頁的 screenshot 彈性超大! 另外一個好處是可以編輯要送出去的 postData,一開始我看他預設也是送 \n 會造成 invalid request 但是只要改成 \r\n 就好囉!

/ect/crontab not running

如果把 cronjob  寫在 /etc/crontab 下,那要注意格式 # Example of job definition: # .---------------- minute (0 - 59) # |  .------------- hour (0 - 23) # |  |  .---------- day of month (1 - 31) # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # |  |  |  |  | # *  *  *  *  * user-name command to be executed 在 "command to be executed" 前面, 要有 user-name... 如果用 crontab -e 的方式, 則不需要 user-name 那個欄位.... # *  *  *  *  *  command to be executed