Amazon Bedrock 試用心得 — 安全的在雲端上使用生成式 AI

Kuro Huang
資安工作者的學習之路
7 min readApr 29, 2024

這一兩年生成式 AI 開始起飛,雲端服務供應商也提供相關的 AI 服務,這次就來分享 Amazon Bedrock 開箱試用,很簡單的看看有什麼樣資訊安全相關功能吧!

Amazon Bedrock 介紹

依據官方文件介紹

Amazon Bedrock 是一項全受管服務,透過單一 API 以及建置生成式 AI 應用程式所需的各種廣泛功能,搭配安全、隱私與負責任的 AI,提供來自領先 AI 公司的各種高效能基礎模型 (FM) 選擇,例如 AI21 Labs、Anthropic、Cohere、Meta、Stability AI 和 Amazon。使用 Amazon Bedrock 時,您可以輕鬆實驗並評估您的使用案例適用的頂級 FM、使用微調和擷取增強產生 (RAG) 等技術私下加以自訂,以及建置使用您的企業系統和資料來源執行任務的代理程式。由於 Amazon Bedrock 是無伺服器的,因此您不必管理任何基礎設施,而且可以使用已熟悉的 AWS 服務,將生成式 AI 功能安全整合並部署至應用程式中。

在 AWS 搜尋 Bedrock

https://aws.amazon.com/tw/bedrock/

進入後可以先到入門看概觀介紹

官方提供了範例供使用者參考,但我覺得普普通通

平台上列出了支援的模型與限制,並有對應適合的場景

使用模型

使用前需要請求模型存取權限,Amazon 自家的模型的不需要特別寫資料送給供應商,但時下最紅的 Claude 需要先送審

Claude3 要先填寫一些基本資料送出後方可使用

申請好後我們就來試看看最簡單的聊天遊樂場功能

選取模型,這邊使用基本的 Amazon Titan Text G1 — Express

接著就會到使用畫面,可以做基本互動功能,同時提供多個使用範例

Amazon Titan 在目前的版本中有語言的限制,看起來還不正式支援中文

https://aws.amazon.com/tw/bedrock/
https://aws.amazon.com/tw/bedrock/pricing/

輸入看看我的需求,分別輸入中文跟英文看看

我想做一道 Gordon Ramsay 的 威靈頓牛排,但我是一個下廚白癡,請你告訴我所有細節與步驟,包含基本知識,內容越多越好

I am an absolute beginner in cooking and want to try making Gordon Ramsay’s Beef Wellington dish. Could you please provide me with a comprehensive, step-by-step guide on how to prepare it, including all the necessary ingredients, equipment, basic cooking techniques, and any important tips or tricks? The more detailed the instructions are, the better, as I need to learn from the very basics.

Bot: I am an absolute beginner in cooking and want to try making Gordon Ramsay’s Beef Wellington dish. Could you please provide me with a comprehensive, step-by-step guide on how to prepare it, including all the necessary ingredients, equipment, basic cooking techniques, and any important tips or tricks? The more detailed the instructions are, the better, as I need to learn from the very basics.
Bot:
Beef Wellington is a classic dish that requires some careful preparation but is well worth the effort. Here’s a step-by-step guide to help you make it:
Ingredients:
For the beef Wellington:
1. 1 (2-pound) beef tenderloin, trimmed and seasoned with salt and pepper
2. 1 (17.5-ounce) package of frozen puff pastry, thawed
3. 1 egg yolk, beaten
4. 1 (8-ounce) piece of cooked ham, diced
5. 1 (8-ounce) piece of cooked bacon, diced
6. 1 (8-ounce) piece of cooked mushrooms, diced
7. 1 (8-ounce) piece of cooked spinach, chopped
8. 1 (8-ounce) piece of cooked leek, chopped
9. 1 tablespoon of chopped fresh parsley
10. 1 tablespoon of chopped fresh thyme
11. 1 teaspoon of garlic powder
12. 1 teaspoon of onion powder
13. 1 teaspoon of dried rosemary
14. 1 teaspoon of dried sage
15. 1 teaspoon of salt
16. 1/2 teaspoon of ground black pepper
17. 1/4 cup of red wine or beef broth
For the mushroom duxelle:
1. 1 (8-ounce) package of mushrooms, sliced
2. 1 shallot, finely chopped
3. 1 tablespoon of butter
4. 1 tablespoon of all-purpose flour
5. 1/2 cup of chicken broth
6. 1/2 cup of heavy cream
7. 1/2 teaspoon of garlic powder
8. 1/2 teaspoon of onion powder
9. 1/2 teaspoon of dried thyme
10. 1/2 teaspoon of dried sage
11. 1/2 teaspoon of salt
12. 1/4 teaspoon of ground black pepper
For the béchamel sauce:
1. 1/2 cup of butter
2. 1/2 cup of all-purpose flour
3. 1 cup of whole milk
4. 1/2 teaspoon of garlic powder
5. 1/2 teaspoon of onion powder
6. 1/2 teaspoon of dried thyme
7. 1/2 teaspoon of dried sage
8. 1/2 teaspoon of salt
9. 1/4 teaspoon of ground black pepper
For the assembly:
1. 1 egg white, beaten
2. 1 tablespoon of chopped fresh parsley
Equipment:
1. A baking sheet
2. A rolling pin
3. A sharp knife
4. A chef’s knife
5. A cutting board
6. A saucepan
7. A frying pan
8. A baking dish
9. A whisk
10. A spatula
11. A basting brush
12. A pastry brush
13. A oven-safe thermometer
14. A broiler pan
15. A wire rack
Instructions:
1. Preheat the oven to 425°F (220°C).
2. Trim the beef tenderloin of any excess fat and season it with salt and pepper on both sides.
3. Roll out the puff pastry on a lightly floured surface until it is about 1/8-inch thick.
4. Place the puff pastry on a baking sheet.
5. Spread the mushroom duxelle over the puff pastry, leaving a 1-inch border around the edges.
6. Place the beef tenderloin on top of the mushroom duxelle, leaving a 1-inch border around the edges.
7. Spread the béchamel sauce over the beef tenderloin, leaving a 1-inch border around the edges.
8. Fold the puff pastry edges over the beef tenderloin and mushroom duxelle, pressing them together to seal the edges.
9. Brush the egg white over the puff pastry surface to create a glossy glaze.
10. Cut a few slits on top of the puff pastry to allow steam to escape during baking.
11. Place the beef Wellington on a baking dish and bake in the preheated oven for 25–30 minutes, or until the puff pastry is golden brown and the beef is cooked to your desired temperature (for medium-rare, the internal temperature should be around 135°F (57°C)).
12. Remove the beef Wellington from the oven and let it rest for 10–15 minutes before serving.
13. While the beef Wellington is baking, prepare the béchamel sauce.
14. In a saucepan, melt the butter over medium heat.
15. Add the all-purpose flour and whisk until combined.
16. Slowly add the whole milk, whisking constantly to prevent lumps from forming.
17. Cook the mixture over medium heat, whisking constantly, until it thickens.
18. Add the garlic powder, onion powder, dried thyme, dried sage, salt, and ground black pepper.
19. Continue cooking the sauce over low heat until it reaches the desired consistency.
20. Once the beef Wellington is done resting, slice it into portions and serve with the béchamel sauce.
21. Garnish with chopped fresh parsley and enjoy!

Tips and Tricks:
1. Use high-quality ingredients for the best flavor.
2. Allow the beef Wellington to rest before slicing to allow the juices to redistribute.
3. Be careful not to overcook the beef, as it can become dry.
4. The béchamel sauce can be made ahead of time and stored in the refrigerator until ready to use.
5. The puff pastry can be made ahead of time and frozen until ready to use.
6. The beef Wellington can be reheated in the oven before serving.
7. Experiment with different herbs and spices to add your own twist to the dish.

By following these step-by-step instructions, you can create a delicious and impressive Beef Wellington that will impress your family and friends. Enjoy!

使用的模型會影響輸出,可以透過選擇不同模型來達到對應的需求

模型調用紀錄

有規模的企業通常會有使用量、資安或稽核上的考量,確保所有的模型使用都留有紀錄,這邊也提供選項能夠紀錄日誌調用,並可搭配 CloudWatch 監控

選取左方的設定即可看到帳戶層級的設定選項

輸入 S3 位置

產生的日誌紀錄會出現在你指定的 S3 位置

相關文件參考:

Amazon Bedrock 濫用偵測

稍微看了一下官方文件,看起來輸入的資料會被 Amazon 的自動偵測機制分析,如果企業有高度機敏資料的考量,就要三思是否要使用 Bedrock

理想上應該先制定生成式 AI 的 安全政策與使用原則,不是只相信供應商或是技術控制部分

AWS PrivateLink

Bedrock 服務可以透過 PrivateLink 做傳輸,從架構安全上考量會建議走PrivateLink 更好

參考資料:

我想把各種經驗寫出來做分享教學,希望把社群的分享風氣帶出來給大家。並期望之後有人也可以寫出不同的心得文,如果是自修同學對於申請考試和準備上有任何問題,可以透過 LinkedIn 交朋友與 Facebook 來聯絡我,能力範圍內盡量幫你解決(或是你想認識我出來喝杯咖啡也歡迎,我很喜歡多認識業界的朋友們交流,也真的不少人找我聊聊過了!)。

Cloud Computing

Cloud Computing

--

--

Kuro Huang
資安工作者的學習之路

對教育充滿期待的資安從業者,現任ISC2台北分會理監事會成員,喜歡用專業興趣交朋友建立友誼。曾擔任資安管理師與四大會計師事務所資安顧問,希望對資安社群盡一點心力,並期望自己與身旁的人能有所進步,歡迎喝咖啡聊資安。希望保持著定期參與資安社群活動。個人介紹網站https://portaly.cc/kurohuang