{"id":2248,"date":"2025-03-24T08:47:53","date_gmt":"2025-03-23T23:47:53","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2248"},"modified":"2025-03-24T08:48:17","modified_gmt":"2025-03-23T23:48:17","slug":"aws-sdk-for-javascript%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%88%9d%e5%bf%83%e8%80%85%e3%81%a7%e3%82%82%e5%b0%8e%e5%85%a5%e3%81%8b%e3%82%89%e5%ae%9f%e8%a3%85%e3%81%be%e3%81%a77","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2248","title":{"rendered":"AWS SDK for JavaScript\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u521d\u5fc3\u8005\u3067\u3082\u5c0e\u5165\u304b\u3089\u5b9f\u88c5\u307e\u30677\u3064\u306e\u30b9\u30c6\u30c3\u30d7"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">AWS SDK for JavaScript\u3068\u306f\uff1f \u57fa\u790e\u77e5\u8b58\u3068\u4e3b\u8981\u6a5f\u80fd\u3092\u89e3\u8aac<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">AWS SDK\u306e\u5f79\u5272\u3068\u91cd\u8981\u6027<\/a>      <\/li>      <li>        <a href=\"#i-2\">\u30d0\u30fc\u30b8\u30e7\u30f32\u3068\u30d0\u30fc\u30b8\u30e7\u30f33\u306e\u9055\u3044\u3068\u9078\u629e\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-3\">\u5bfe\u5fdc\u3057\u3066\u3044\u308bAWS\u30b5\u30fc\u30d3\u30b9\u306e\u7bc4\u56f2<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-4\">\u74b0\u5883\u69cb\u7bc9\uff1a3\u30b9\u30c6\u30c3\u30d7\u3067\u59cb\u3081\u308bAWS SDK\u958b\u767a\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-5\">Node.js\u3068npm\u74b0\u5883\u306e\u6e96\u5099\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-6\">AWS\u8a8d\u8a3c\u60c5\u5831\u306e\u8a2d\u5b9a\u3068\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-7\">\u958b\u767a\u306b\u5fc5\u8981\u306aIAM\u6a29\u9650\u306e\u8a2d\u5b9a<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-8\">AWS SDK for JavaScript\u306b\u3088\u308b\u57fa\u672c\u7684\u306aAWS\u30ea\u30bd\u30fc\u30b9\u64cd\u4f5c<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-9\">S3\u30d0\u30b1\u30c3\u30c8\u306e\u4f5c\u6210\u30fb\u524a\u9664\u30fb\u4e00\u89a7\u53d6\u5f97\u306e\u30b3\u30fc\u30c9\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-10\">EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u8d77\u52d5\u30fb\u505c\u6b62\u30fb\u72b6\u614b\u78ba\u8a8d\u306e\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-11\">DynamoDB\u3067\u306eCRUD\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u4f8b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-12\">\u975e\u540c\u671f\u51e6\u7406\u3068\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-13\">Promise\u3001async\/await \u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/a>      <\/li>      <li>        <a href=\"#i-14\">\u30ea\u30c8\u30e9\u30a4\u51e6\u7406\u3068\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u306e\u5b9f\u88c5\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-15\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u89e3\u8aad\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-16\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-17\">S3\u3078\u306e\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6a5f\u80fd\u306e\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-18\">Lambda\u95a2\u6570\u306e\u30c7\u30d7\u30ed\u30a4\u3068\u7ba1\u7406\u306e\u81ea\u52d5\u5316<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-19\">CloudWatch\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u76e3\u8996\u30b7\u30b9\u30c6\u30e0\u69cb\u7bc9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-20\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-21\">\u8a8d\u8a3c\u60c5\u5831\u306e\u5b89\u5168\u306a\u7ba1\u7406\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-22\">\u63a5\u7d9a\u30d7\u30fc\u30eb\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u8a2d\u5b9a<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-23\">\u30b3\u30b9\u30c8\u6700\u9069\u5316\u306e\u305f\u3081\u306e SDK \u8a2d\u5b9a<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-24\">AWS SDK for JavaScript\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u30ac\u30a4\u30c9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-25\">\u4e00\u822c\u7684\u306a\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-26\">\u30c7\u30d0\u30c3\u30b0\u30c4\u30fc\u30eb\u3068\u30ed\u30b0\u53ce\u96c6\u306e\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-27\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u554f\u984c\u306e\u8a3a\u65ad\u3068\u6539\u5584<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">AWS SDK for JavaScript\u3068\u306f\uff1f \u57fa\u790e\u77e5\u8b58\u3068\u4e3b\u8981\u6a5f\u80fd\u3092\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">AWS SDK\u306e\u5f79\u5272\u3068\u91cd\u8981\u6027<\/h3>\n\n\n\n<p>AWS SDK for JavaScript\u306f\u3001AWS\u306e\u30af\u30e9\u30a6\u30c9\u30b5\u30fc\u30d3\u30b9\u3092JavaScript\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u7c21\u5358\u306b\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u516c\u5f0f\u958b\u767a\u30ad\u30c3\u30c8\u3067\u3059\u3002\u3053\u306eSDK\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001Node.js\u3084\u30d6\u30e9\u30a6\u30b6\u74b0\u5883\u304b\u3089AWS\u306e\u69d8\u3005\u306a\u30b5\u30fc\u30d3\u30b9\u3092\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u958b\u767a\u8005\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5229\u70b9\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AWS API\u3078\u306e\u6a19\u6e96\u5316\u3055\u308c\u305f\u30a2\u30af\u30bb\u30b9\u65b9\u6cd5<\/li>\n\n\n\n<li>\u8a8d\u8a3c\u60c5\u5831\u306e\u5b89\u5168\u306a\u7ba1\u7406<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u7d71\u4e00\u7684\u306a\u5b9f\u88c5<\/li>\n\n\n\n<li>TypeScript\u306b\u3088\u308b\u578b\u5b89\u5168\u306a\u958b\u767a<\/li>\n<\/ul>\n\n\n\n<p>\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ AWS SDK\u306eS3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u521d\u671f\u5316\u3059\u308b\u4f8b\nimport { S3Client } from \"@aws-sdk\/client-s3\";\n\nconst client = new S3Client({\n    region: \"ap-northeast-1\",\n    credentials: {\n        accessKeyId: \"YOUR_ACCESS_KEY\",\n        secretAccessKey: \"YOUR_SECRET_KEY\"\n    }\n});<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u30d0\u30fc\u30b8\u30e7\u30f32\u3068\u30d0\u30fc\u30b8\u30e7\u30f33\u306e\u9055\u3044\u3068\u9078\u629e\u65b9\u6cd5<\/h3>\n\n\n\n<p>AWS SDK for JavaScript\u306b\u306f\u3001\u73fe\u5728\u30d0\u30fc\u30b8\u30e7\u30f32\uff08v2\uff09\u3068\u30d0\u30fc\u30b8\u30e7\u30f33\uff08v3\uff09\u304c\u5b58\u5728\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u8868\u3067\u4e3b\u306a\u9055\u3044\u3092\u6bd4\u8f03\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff1a<\/p>\n\n\n<div id=\"id-39ccc2ee-7cb5-4978-9ceb-dd514fc39ce2\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7279\u5fb4<\/th><th>\u30d0\u30fc\u30b8\u30e7\u30f32<\/th><th>\u30d0\u30fc\u30b8\u30e7\u30f33<\/th><\/tr><\/thead><tbody><tr><td>\u30d1\u30c3\u30b1\u30fc\u30b8\u69cb\u9020<\/td><td>\u30e2\u30ce\u30ea\u30b7\u30c3\u30af<\/td><td>\u30e2\u30b8\u30e5\u30e9\u30fc<\/td><\/tr><tr><td>\u975e\u540c\u671f\u51e6\u7406<\/td><td>\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\/Promise<\/td><td>Promise\/async-await<\/td><\/tr><tr><td>TypeScript\u5bfe\u5fdc<\/td><td>\u90e8\u5206\u7684<\/td><td>\u5b8c\u5168\u5bfe\u5fdc<\/td><\/tr><tr><td>\u30d0\u30f3\u30c9\u30eb\u30b5\u30a4\u30ba<\/td><td>\u5927\u304d\u3044<\/td><td>Tree-shaking\u5bfe\u5fdc\u3067\u5c0f\u3055\u3044<\/td><\/tr><tr><td>\u4fdd\u5b88\u72b6\u614b<\/td><td>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30e2\u30fc\u30c9<\/td><td>\u6d3b\u767a\u306a\u958b\u767a\u7d99\u7d9a\u4e2d<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p>\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u30d0\u30fc\u30b8\u30e7\u30f33\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3092\u5f37\u304f\u63a8\u5968\u3057\u307e\u3059\u3002\u305d\u306e\u7406\u7531\u306f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e2\u30c0\u30f3\u306aJavaScript\u6a5f\u80fd\u306e\u5b8c\u5168\u30b5\u30dd\u30fc\u30c8<\/li>\n\n\n\n<li>\u512a\u308c\u305f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u5c0f\u3055\u306a\u30d0\u30f3\u30c9\u30eb\u30b5\u30a4\u30ba<\/li>\n\n\n\n<li>\u3088\u308a\u512a\u308c\u305f\u578b\u30b7\u30b9\u30c6\u30e0\u306e\u30b5\u30dd\u30fc\u30c8<\/li>\n\n\n\n<li>\u6700\u65b0\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u66f4\u65b0\u306e\u7d99\u7d9a\u7684\u306a\u63d0\u4f9b<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u5bfe\u5fdc\u3057\u3066\u3044\u308bAWS\u30b5\u30fc\u30d3\u30b9\u306e\u7bc4\u56f2<\/h3>\n\n\n\n<p>AWS SDK for JavaScript\u306f\u3001AWS\u306e\u4e3b\u8981\u306a\u30b5\u30fc\u30d3\u30b9\u3092\u5e83\u304f\u30ab\u30d0\u30fc\u3057\u3066\u3044\u307e\u3059\u3002\u30ab\u30c6\u30b4\u30ea\u5225\u306b\u898b\u308b\u3068\uff1a<\/p>\n\n\n\n<p><strong>\u30b3\u30f3\u30d4\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u30b5\u30fc\u30d3\u30b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>EC2\uff1a\u4eee\u60f3\u30b5\u30fc\u30d0\u30fc\u306e\u7ba1\u7406<\/li>\n\n\n\n<li>Lambda\uff1a\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u95a2\u6570\u306e\u5b9f\u884c<\/li>\n\n\n\n<li>ECS\uff1a\u30b3\u30f3\u30c6\u30ca\u30aa\u30fc\u30b1\u30b9\u30c8\u30ec\u30fc\u30b7\u30e7\u30f3<\/li>\n<\/ul>\n\n\n\n<p><strong>\u30b9\u30c8\u30ec\u30fc\u30b8\u30b5\u30fc\u30d3\u30b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>S3\uff1a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30b9\u30c8\u30ec\u30fc\u30b8<\/li>\n\n\n\n<li>EBS\uff1a\u30d6\u30ed\u30c3\u30af\u30b9\u30c8\u30ec\u30fc\u30b8<\/li>\n\n\n\n<li>EFS\uff1a\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0<\/li>\n<\/ul>\n\n\n\n<p><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b5\u30fc\u30d3\u30b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>DynamoDB\uff1aNoSQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/li>\n\n\n\n<li>RDS\uff1a\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/li>\n\n\n\n<li>Aurora\uff1a\u30de\u30cd\u30fc\u30b8\u30c9\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/li>\n<\/ul>\n\n\n\n<p><strong>\u30cd\u30c3\u30c8\u30ef\u30fc\u30ad\u30f3\u30b0\u30b5\u30fc\u30d3\u30b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>VPC\uff1a\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af<\/li>\n\n\n\n<li>Route 53\uff1aDNS\u7ba1\u7406<\/li>\n\n\n\n<li>CloudFront\uff1aCDN\u30b5\u30fc\u30d3\u30b9<\/li>\n<\/ul>\n\n\n\n<p>\u305d\u308c\u305e\u308c\u306e\u30b5\u30fc\u30d3\u30b9\u306f\u500b\u5225\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3001\u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u5fc5\u8981\u306a\u30b5\u30fc\u30d3\u30b9\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u307f\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nimport { S3Client } from \"@aws-sdk\/client-s3\";\nimport { DynamoDBClient } from \"@aws-sdk\/client-dynamodb\";\nimport { LambdaClient } from \"@aws-sdk\/client-lambda\";\n\n\/\/ \u30b5\u30fc\u30d3\u30b9\u56fa\u6709\u306e\u64cd\u4f5c\u30b3\u30de\u30f3\u30c9\u3082\u30e2\u30b8\u30e5\u30e9\u30fc\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\nimport { PutObjectCommand } from \"@aws-sdk\/client-s3\";\nimport { GetItemCommand } from \"@aws-sdk\/client-dynamodb\";<\/pre>\n\n\n\n<p>\u3053\u306e\u30e2\u30b8\u30e5\u30e9\u30fc\u69cb\u9020\u306b\u3088\u308a\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30f3\u30c9\u30eb\u30b5\u30a4\u30ba\u3092\u6700\u9069\u5316\u3067\u304d\u3001\u5fc5\u8981\u306a\u30b5\u30fc\u30d3\u30b9\u3060\u3051\u3092\u542b\u3081\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u3055\u3089\u306b\u3001\u5404\u30b5\u30fc\u30d3\u30b9\u306f\u4e00\u8cab\u3057\u305f\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u306b\u5f93\u3063\u3066\u3044\u308b\u305f\u3081\u30011\u3064\u306e\u30b5\u30fc\u30d3\u30b9\u306e\u4f7f\u3044\u65b9\u3092\u5b66\u3079\u3070\u3001\u4ed6\u306e\u30b5\u30fc\u30d3\u30b9\u3082\u540c\u69d8\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-4\">\u74b0\u5883\u69cb\u7bc9\uff1a3\u30b9\u30c6\u30c3\u30d7\u3067\u59cb\u3081\u308bAWS SDK\u958b\u767a\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">Node.js\u3068npm\u74b0\u5883\u306e\u6e96\u5099\u65b9\u6cd5<\/h3>\n\n\n\n<p>AWS SDK for JavaScript\u3092\u4f7f\u7528\u3059\u308b\u306b\u306f\u3001\u307e\u305a\u9069\u5207\u306aNode.js\u74b0\u5883\u304c\u5fc5\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u74b0\u5883\u3092\u6e96\u5099\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Node.js\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># macOS\u306e\u5834\u5408\uff08Homebrew\u3092\u4f7f\u7528\uff09\nbrew install node\n\n# Windows\u306e\u5834\u5408\n# Node.js\u306e\u516c\u5f0f\u30b5\u30a4\u30c8\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Node.js\u3068npm\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">node --version  # v14.0.0\u4ee5\u4e0a\u3092\u63a8\u5968\nnpm --version   # v6.0.0\u4ee5\u4e0a\u3092\u63a8\u5968<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u521d\u671f\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir my-aws-project\ncd my-aws-project\nnpm init -y<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>AWS SDK\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u5fc5\u8981\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm install @aws-sdk\/client-s3 @aws-sdk\/client-dynamodb<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">AWS\u8a8d\u8a3c\u60c5\u5831\u306e\u8a2d\u5b9a\u3068\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p>AWS SDK\u3092\u4f7f\u7528\u3059\u308b\u306b\u306f\u3001\u9069\u5207\u306a\u8a8d\u8a3c\u60c5\u5831\u306e\u8a2d\u5b9a\u304c\u4e0d\u53ef\u6b20\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u65b9\u6cd5\u304b\u3089\u3001\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u5fdc\u3058\u3066\u6700\u9069\u306a\u65b9\u6cd5\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>AWS CLI\u8a2d\u5b9a\uff08\u63a8\u5968\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># AWS CLI\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm install -g aws-cli\n\n# \u8a8d\u8a3c\u60c5\u5831\u306e\u8a2d\u5b9a\naws configure\n\n# \u4ee5\u4e0b\u306e\u60c5\u5831\u3092\u5165\u529b\nAWS Access Key ID: YOUR_ACCESS_KEY\nAWS Secret Access Key: YOUR_SECRET_KEY\nDefault region name: ap-northeast-1\nDefault output format: json<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u74b0\u5883\u5909\u6570\u306e\u4f7f\u7528<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Linux\/macOS\nexport AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY\nexport AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY\nexport AWS_REGION=ap-northeast-1\n\n# Windows\nset AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY\nset AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY\nset AWS_REGION=ap-northeast-1<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30af\u30ec\u30c7\u30f3\u30b7\u30e3\u30eb\u30d5\u30a1\u30a4\u30eb\u306e\u76f4\u63a5\u7de8\u96c6<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># ~\/.aws\/credentials<\/pre>\n\n\n[default]\n\n\n\n<p>aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_SECRET_KEY # ~\/.aws\/config<\/p>\n\n\n[default]\n\n\n\n<p>region = ap-northeast-1<\/p>\n\n\n\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u672c\u756a\u74b0\u5883\u3067\u306f\u74b0\u5883\u5909\u6570\u3084AWS Systems Manager Parameter Store\u3092\u4f7f\u7528<\/li>\n\n\n\n<li>\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u5b9a\u671f\u7684\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u306b\u306f\u8a8d\u8a3c\u60c5\u5831\u3092\u7d76\u5bfe\u306b\u30b3\u30df\u30c3\u30c8\u3057\u306a\u3044<\/li>\n\n\n\n<li>\u6700\u5c0f\u6a29\u9650\u306e\u539f\u5247\u306b\u5f93\u3046<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">\u958b\u767a\u306b\u5fc5\u8981\u306aIAM\u6a29\u9650\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n<p>AWS SDK\u3092\u4f7f\u7528\u3059\u308b\u969b\u306f\u3001\u9069\u5207\u306aIAM\u6a29\u9650\u306e\u8a2d\u5b9a\u304c\u91cd\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u5fc5\u8981\u306a\u6a29\u9650\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>IAM\u30dd\u30ea\u30b7\u30fc\u306e\u4f5c\u6210<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"s3:ListBucket\",\n                \"s3:GetObject\",\n                \"s3:PutObject\",\n                \"dynamodb:Query\",\n                \"dynamodb:Scan\",\n                \"dynamodb:GetItem\",\n                \"dynamodb:PutItem\"\n            ],\n            \"Resource\": [\n                \"arn:aws:s3:::your-bucket-name\/*\",\n                \"arn:aws:dynamodb:region:account-id:table\/your-table-name\"\n            ]\n        }\n    ]\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>IAM\u30ed\u30fc\u30eb\u306e\u4f5c\u6210\u3068\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3067IAM\u30ed\u30fc\u30eb\u3092\u4f5c\u6210<\/li>\n\n\n\n<li>\u4e0a\u8a18\u306e\u30dd\u30ea\u30b7\u30fc\u3092\u30a2\u30bf\u30c3\u30c1<\/li>\n\n\n\n<li>EC2\u3084Lambda\u306a\u3069\u306e\u30b5\u30fc\u30d3\u30b9\u306b\u95a2\u9023\u4ed8\u3051<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u6a29\u9650\u306e\u691c\u8a3c<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u6a29\u9650\u306e\u30c6\u30b9\u30c8\u7528\u30b3\u30fc\u30c9\nimport { S3Client, ListBucketsCommand } from \"@aws-sdk\/client-s3\";\n\nconst client = new S3Client({ region: \"ap-northeast-1\" });\n\nasync function testPermissions() {\n    try {\n        const command = new ListBucketsCommand({});\n        const response = await client.send(command);\n        console.log(\"\u6a29\u9650\u306e\u78ba\u8a8d\u6210\u529f:\", response.Buckets);\n    } catch (error) {\n        console.error(\"\u6a29\u9650\u30a8\u30e9\u30fc:\", error);\n    }\n}\n\ntestPermissions();<\/pre>\n\n\n\n<p>\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u30d2\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>AccessDenied<\/code>\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001IAM\u30dd\u30ea\u30b7\u30fc\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li><code>InvalidAccessKeyId<\/code>\u306e\u5834\u5408\u3001\u8a8d\u8a3c\u60c5\u5831\u306e\u518d\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30ea\u30fc\u30b8\u30e7\u30f3\u306e\u8a2d\u5b9a\u304c\u6b63\u3057\u3044\u3053\u3068\u3092\u78ba\u8a8d<\/li>\n\n\n\n<li>VPC\u5185\u3067\u306e\u30a2\u30af\u30bb\u30b9\u306e\u5834\u5408\u3001\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u8a2d\u5b9a\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001AWS SDK\u3092\u4f7f\u7528\u3059\u308b\u6e96\u5099\u304c\u6574\u3044\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9f\u969b\u306eAWS\u30ea\u30bd\u30fc\u30b9\u64cd\u4f5c\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-8\">AWS SDK for JavaScript\u306b\u3088\u308b\u57fa\u672c\u7684\u306aAWS\u30ea\u30bd\u30fc\u30b9\u64cd\u4f5c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">S3\u30d0\u30b1\u30c3\u30c8\u306e\u4f5c\u6210\u30fb\u524a\u9664\u30fb\u4e00\u89a7\u53d6\u5f97\u306e\u30b3\u30fc\u30c9\u5b9f\u88c5<\/h3>\n\n\n\n<p>S3\u306f\u3001AWS\u306e\u4ee3\u8868\u7684\u306a\u30b9\u30c8\u30ec\u30fc\u30b8\u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u57fa\u672c\u7684\u306a\u64cd\u4f5c\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>S3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { S3Client } from \"@aws-sdk\/client-s3\";\nimport { \n    CreateBucketCommand,\n    DeleteBucketCommand,\n    ListBucketsCommand,\n    PutObjectCommand,\n    GetObjectCommand\n} from \"@aws-sdk\/client-s3\";\n\nconst s3Client = new S3Client({ region: \"ap-northeast-1\" });<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30d0\u30b1\u30c3\u30c8\u306e\u4f5c\u6210<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function createBucket(bucketName) {\n    try {\n        const command = new CreateBucketCommand({\n            Bucket: bucketName,\n            \/\/ \u6771\u4eac\u30ea\u30fc\u30b8\u30e7\u30f3\u306e\u5834\u5408\n            CreateBucketConfiguration: {\n                LocationConstraint: \"ap-northeast-1\"\n            }\n        });\n\n        const response = await s3Client.send(command);\n        console.log(`\u30d0\u30b1\u30c3\u30c8\u4f5c\u6210\u6210\u529f: ${bucketName}`);\n        return response;\n    } catch (error) {\n        console.error(\"\u30d0\u30b1\u30c3\u30c8\u4f5c\u6210\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30d0\u30b1\u30c3\u30c8\u4e00\u89a7\u306e\u53d6\u5f97<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function listBuckets() {\n    try {\n        const command = new ListBucketsCommand({});\n        const response = await s3Client.send(command);\n\n        console.log(\"\u30d0\u30b1\u30c3\u30c8\u4e00\u89a7:\");\n        response.Buckets?.forEach(bucket =&gt; {\n            console.log(`- ${bucket.Name} (\u4f5c\u6210\u65e5: ${bucket.CreationDate})`);\n        });\n\n        return response.Buckets;\n    } catch (error) {\n        console.error(\"\u30d0\u30b1\u30c3\u30c8\u4e00\u89a7\u53d6\u5f97\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function uploadFile(bucketName, key, fileContent) {\n    try {\n        const command = new PutObjectCommand({\n            Bucket: bucketName,\n            Key: key,\n            Body: fileContent,\n            ContentType: 'application\/json' \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306b\u5fdc\u3058\u3066\u8a2d\u5b9a\n        });\n\n        const response = await s3Client.send(command);\n        console.log(`\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6210\u529f: ${key}`);\n        return response;\n    } catch (error) {\n        console.error(\"\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u8d77\u52d5\u30fb\u505c\u6b62\u30fb\u72b6\u614b\u78ba\u8a8d\u306e\u65b9\u6cd5<\/h3>\n\n\n\n<p>EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u57fa\u672c\u64cd\u4f5c\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>EC2\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { EC2Client } from \"@aws-sdk\/client-ec2\";\nimport {\n    RunInstancesCommand,\n    StartInstancesCommand,\n    StopInstancesCommand,\n    DescribeInstancesCommand\n} from \"@aws-sdk\/client-ec2\";\n\nconst ec2Client = new EC2Client({ region: \"ap-northeast-1\" });<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u8d77\u52d5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function launchInstance(imageId, instanceType) {\n    try {\n        const command = new RunInstancesCommand({\n            ImageId: imageId, \/\/ \u4f8b: \"ami-0c3fd0f5d33134a76\"\n            InstanceType: instanceType, \/\/ \u4f8b: \"t2.micro\"\n            MinCount: 1,\n            MaxCount: 1,\n            TagSpecifications: [\n                {\n                    ResourceType: \"instance\",\n                    Tags: [\n                        {\n                            Key: \"Name\",\n                            Value: \"MyTestInstance\"\n                        }\n                    ]\n                }\n            ]\n        });\n\n        const response = await ec2Client.send(command);\n        console.log(\"\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u8d77\u52d5\u6210\u529f:\", response.Instances[0].InstanceId);\n        return response.Instances[0];\n    } catch (error) {\n        console.error(\"\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u8d77\u52d5\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u72b6\u614b\u78ba\u8a8d<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function checkInstanceStatus(instanceId) {\n    try {\n        const command = new DescribeInstancesCommand({\n            InstanceIds: [instanceId]\n        });\n\n        const response = await ec2Client.send(command);\n        const instance = response.Reservations[0].Instances[0];\n        console.log(`\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u72b6\u614b: ${instance.State.Name}`);\n        return instance.State.Name;\n    } catch (error) {\n        console.error(\"\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u72b6\u614b\u78ba\u8a8d\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">DynamoDB\u3067\u306eCRUD\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u4f8b<\/h3>\n\n\n\n<p>DynamoDB\u3092\u4f7f\u7528\u3057\u305f\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u64cd\u4f5c\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>DynamoDB\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { DynamoDBClient } from \"@aws-sdk\/client-dynamodb\";\nimport {\n    DynamoDBDocumentClient,\n    PutCommand,\n    GetCommand,\n    UpdateCommand,\n    DeleteCommand,\n    ScanCommand\n} from \"@aws-sdk\/lib-dynamodb\";\n\nconst client = new DynamoDBClient({ region: \"ap-northeast-1\" });\nconst docClient = DynamoDBDocumentClient.from(client);<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\u3068\u66f4\u65b0<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function createItem(tableName, item) {\n    try {\n        const command = new PutCommand({\n            TableName: tableName,\n            Item: item,\n            \/\/ \u6761\u4ef6\u4ed8\u304d\u66f8\u304d\u8fbc\u307f\u306e\u4f8b\n            ConditionExpression: \"attribute_not_exists(id)\"\n        });\n\n        const response = await docClient.send(command);\n        console.log(\"\u30a2\u30a4\u30c6\u30e0\u4f5c\u6210\u6210\u529f\");\n        return response;\n    } catch (error) {\n        console.error(\"\u30a2\u30a4\u30c6\u30e0\u4f5c\u6210\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nconst item = {\n    id: \"user123\",\n    name: \"\u5c71\u7530\u592a\u90ce\",\n    age: 30,\n    email: \"yamada@example.com\"\n};\nawait createItem(\"Users\", item);<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u306e\u53d6\u5f97<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function getItem(tableName, key) {\n    try {\n        const command = new GetCommand({\n            TableName: tableName,\n            Key: key\n        });\n\n        const response = await docClient.send(command);\n        console.log(\"\u30a2\u30a4\u30c6\u30e0\u53d6\u5f97\u6210\u529f:\", response.Item);\n        return response.Item;\n    } catch (error) {\n        console.error(\"\u30a2\u30a4\u30c6\u30e0\u53d6\u5f97\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nconst key = { id: \"user123\" };\nconst user = await getItem(\"Users\", key);<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u306e\u66f4\u65b0<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function updateItem(tableName, key, updates) {\n    try {\n        const command = new UpdateCommand({\n            TableName: tableName,\n            Key: key,\n            UpdateExpression: \"set #name = :name, age = :age\",\n            ExpressionAttributeNames: {\n                \"#name\": \"name\" \/\/ name \u306f\u4e88\u7d04\u8a9e\u306e\u305f\u3081\n            },\n            ExpressionAttributeValues: {\n                \":name\": updates.name,\n                \":age\": updates.age\n            },\n            ReturnValues: \"ALL_NEW\"\n        });\n\n        const response = await docClient.send(command);\n        console.log(\"\u30a2\u30a4\u30c6\u30e0\u66f4\u65b0\u6210\u529f:\", response.Attributes);\n        return response.Attributes;\n    } catch (error) {\n        console.error(\"\u30a2\u30a4\u30c6\u30e0\u66f4\u65b0\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nconst updates = {\n    name: \"\u5c71\u7530\u6b21\u90ce\",\n    age: 31\n};\nawait updateItem(\"Users\", { id: \"user123\" }, updates);<\/pre>\n\n\n\n<p>\u5b9f\u88c5\u306e\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3059\u3079\u3066\u306e\u64cd\u4f5c\u3067\u9069\u5207\u306a\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u5b9f\u88c5<\/li>\n\n\n\n<li>\u975e\u540c\u671f\u51e6\u7406\u3092\u9069\u5207\u306b\u7ba1\u7406\uff08async\/await\u4f7f\u7528\uff09<\/li>\n\n\n\n<li>\u6761\u4ef6\u4ed8\u304d\u66f8\u304d\u8fbc\u307f\u306b\u3088\u308b\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u78ba\u4fdd<\/li>\n\n\n\n<li>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u6d3b\u7528\u306b\u3088\u308b\u52b9\u7387\u5316<\/li>\n\n\n\n<li>\u30ea\u30c8\u30e9\u30a4\u51e6\u7406\u306e\u5b9f\u88c5\u691c\u8a0e<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u64cd\u4f5c\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u8907\u96d1\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u64cd\u4f5c\u3092\u3088\u308a\u52b9\u7387\u7684\u306b\u884c\u3046\u305f\u3081\u306e\u975e\u540c\u671f\u51e6\u7406\u3068\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-12\">\u975e\u540c\u671f\u51e6\u7406\u3068\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">Promise\u3001async\/await \u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/h3>\n\n\n\n<p>AWS SDK for JavaScript v3\u306f\u3001\u5b8c\u5168\u306b\u975e\u540c\u671f\u51e6\u7406\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u52b9\u679c\u7684\u306a\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u57fa\u672c\u7684\u306aPromise\u30d1\u30bf\u30fc\u30f3<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { S3Client, GetObjectCommand } from \"@aws-sdk\/client-s3\";\n\nconst s3Client = new S3Client({ region: \"ap-northeast-1\" });\n\n\/\/ Promise\u30c1\u30a7\u30fc\u30f3\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\nfunction getObjectFromS3(bucket, key) {\n    const command = new GetObjectCommand({\n        Bucket: bucket,\n        Key: key\n    });\n\n    return s3Client.send(command)\n        .then(response =&gt; {\n            console.log(\"\u30d5\u30a1\u30a4\u30eb\u53d6\u5f97\u6210\u529f\");\n            return response.Body;\n        })\n        .catch(error =&gt; {\n            console.error(\"\u30d5\u30a1\u30a4\u30eb\u53d6\u5f97\u30a8\u30e9\u30fc:\", error);\n            throw error;\n        });\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>async\/await\u30d1\u30bf\u30fc\u30f3\uff08\u63a8\u5968\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { DynamoDBClient } from \"@aws-sdk\/client-dynamodb\";\nimport { DynamoDBDocumentClient, QueryCommand } from \"@aws-sdk\/lib-dynamodb\";\n\nconst client = new DynamoDBClient({ region: \"ap-northeast-1\" });\nconst docClient = DynamoDBDocumentClient.from(client);\n\n\/\/ async\/await\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\nasync function queryUserData(userId) {\n    try {\n        const command = new QueryCommand({\n            TableName: \"Users\",\n            KeyConditionExpression: \"id = :userId\",\n            ExpressionAttributeValues: {\n                \":userId\": userId\n            }\n        });\n\n        const response = await docClient.send(command);\n        console.log(\"\u30af\u30a8\u30ea\u6210\u529f:\", response.Items);\n        return response.Items;\n    } catch (error) {\n        console.error(\"\u30af\u30a8\u30ea\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u4e26\u5217\u51e6\u7406\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function processMultipleFiles(bucketName, keys) {\n    try {\n        \/\/ \u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u3092\u4e26\u5217\u5b9f\u884c\n        const promises = keys.map(key =&gt; {\n            const command = new GetObjectCommand({\n                Bucket: bucketName,\n                Key: key\n            });\n            return s3Client.send(command);\n        });\n\n        const results = await Promise.all(promises);\n        console.log(`${results.length}\u4ef6\u306e\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u5b8c\u4e86`);\n        return results;\n    } catch (error) {\n        console.error(\"\u4e26\u5217\u51e6\u7406\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u30ea\u30c8\u30e9\u30a4\u51e6\u7406\u3068\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u306e\u5b9f\u88c5\u65b9\u6cd5<\/h3>\n\n\n\n<p>AWS SDK\u306e\u64cd\u4f5c\u306f\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u554f\u984c\u3084\u4e00\u6642\u7684\u306a\u30b5\u30fc\u30d3\u30b9\u306e\u4e0d\u5177\u5408\u3067\u5931\u6557\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u9069\u5207\u306a\u30ea\u30c8\u30e9\u30a4\u51e6\u7406\u3068\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30ea\u30c8\u30e9\u30a4\u30ed\u30b8\u30c3\u30af\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function withRetry(operation, maxRetries = 3, delay = 1000) {\n    let lastError;\n\n    for (let i = 0; i &lt; maxRetries; i++) {\n        try {\n            return await operation();\n        } catch (error) {\n            console.warn(`\u8a66\u884c ${i + 1}\/${maxRetries} \u5931\u6557:`, error);\n            lastError = error;\n\n            \/\/ \u4e00\u6642\u7684\u306a\u30a8\u30e9\u30fc\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\n            if (!isRetryableError(error)) {\n                throw error;\n            }\n\n            \/\/ \u6307\u6570\u30d0\u30c3\u30af\u30aa\u30d5\n            await new Promise(resolve =&gt; \n                setTimeout(resolve, delay * Math.pow(2, i))\n            );\n        }\n    }\n\n    throw new Error(`${maxRetries}\u56de\u30ea\u30c8\u30e9\u30a4\u5f8c\u3082\u5931\u6557: ${lastError}`);\n}\n\n\/\/ \u30ea\u30c8\u30e9\u30a4\u53ef\u80fd\u306a\u30a8\u30e9\u30fc\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\nfunction isRetryableError(error) {\n    return [\n        'ThrottlingException',\n        'RequestLimitExceeded',\n        'NetworkingError',\n        'ProvisionedThroughputExceededException'\n    ].includes(error.name);\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nasync function uploadWithRetry(bucket, key, body) {\n    return withRetry(async () =&gt; {\n        const command = new PutObjectCommand({\n            Bucket: bucket,\n            Key: key,\n            Body: body\n        });\n        return await s3Client.send(command);\n    });\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">async function withTimeout(operation, timeoutMs = 5000) {\n    const timeoutPromise = new Promise((_, reject) =&gt; {\n        setTimeout(() =&gt; {\n            reject(new Error(`\u64cd\u4f5c\u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\uff08${timeoutMs}ms\uff09`));\n        }, timeoutMs);\n    });\n\n    return Promise.race([operation(), timeoutPromise]);\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nasync function getObjectWithTimeout(bucket, key) {\n    return withTimeout(async () =&gt; {\n        const command = new GetObjectCommand({\n            Bucket: bucket,\n            Key: key\n        });\n        return await s3Client.send(command);\n    }, 10000); \/\/ 10\u79d2\u3067\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u89e3\u8aad\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h3>\n\n\n\n<p>AWS SDK\u304b\u3089\u8fd4\u3055\u308c\u308b\u30a8\u30e9\u30fc\u3092\u9069\u5207\u306b\u51e6\u7406\u3057\u3001\u554f\u984c\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u306f\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u30bf\u30a4\u30d7\u306e\u5206\u985e\u3068\u51e6\u7406<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">function handleAWSError(error) {\n    \/\/ \u30a8\u30e9\u30fc\u306e\u7a2e\u985e\u306b\u57fa\u3065\u3044\u3066\u9069\u5207\u306a\u51e6\u7406\u3092\u5b9f\u884c\n    switch(error.name) {\n        case 'AccessDeniedException':\n            console.error('\u6a29\u9650\u30a8\u30e9\u30fc: IAM\u30dd\u30ea\u30b7\u30fc\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044');\n            break;\n        case 'ResourceNotFoundException':\n            console.error('\u30ea\u30bd\u30fc\u30b9\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093');\n            break;\n        case 'ValidationException':\n            console.error('\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u7121\u52b9\u3067\u3059:', error.message);\n            break;\n        case 'ThrottlingException':\n            console.error('API\u30ea\u30af\u30a8\u30b9\u30c8\u5236\u9650\u306b\u9054\u3057\u307e\u3057\u305f');\n            break;\n        default:\n            console.error('\u4e88\u671f\u305b\u306c\u30a8\u30e9\u30fc:', error);\n    }\n\n    \/\/ \u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u8a73\u7d30\u8a18\u9332\n    console.error({\n        errorName: error.name,\n        message: error.message,\n        requestId: error.$metadata?.requestId,\n        httpStatusCode: error.$metadata?.httpStatusCode,\n        timestamp: new Date().toISOString()\n    });\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nasync function safeOperation() {\n    try {\n        \/\/ AWS\u64cd\u4f5c\u306e\u5b9f\u884c\n        const command = new ListBucketsCommand({});\n        return await s3Client.send(command);\n    } catch (error) {\n        handleAWSError(error);\n        throw error; \/\/ \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u4e0a\u4f4d\u3078\u30a8\u30e9\u30fc\u3092\u4f1d\u64ad\n    }\n}<\/pre>\n\n\n\n<p>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u306e\u5206\u985e\u3068\u9069\u5207\u306a\u51e6\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e00\u6642\u7684\u306a\u30a8\u30e9\u30fc \u2192 \u30ea\u30c8\u30e9\u30a4<\/li>\n\n\n\n<li>\u6a29\u9650\u30a8\u30e9\u30fc \u2192 IAM\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc \u2192 \u5165\u529b\u5024\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u5b58\u5728\u3057\u306a\u3044\u30ea\u30bd\u30fc\u30b9 \u2192 \u30ea\u30bd\u30fc\u30b9\u4f5c\u6210\u307e\u305f\u306f\u4ee3\u66ff\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ed\u30b0\u8a18\u9332\u306e\u91cd\u8981\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u306e\u8a73\u7d30\u60c5\u5831\u3092\u8a18\u9332<\/li>\n\n\n\n<li>\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3068\u30ea\u30af\u30a8\u30b9\u30c8ID\u306e\u4fdd\u5b58<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306e\u4fdd\u6301<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u901a\u77e5\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u91cd\u8981\u306a\u30a8\u30e9\u30fc\u306e\u7ba1\u7406\u8005\u901a\u77e5<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u60c5\u5831\u306e\u53ce\u96c6<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5805\u7262\u306aAWS\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-16\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">S3\u3078\u306e\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6a5f\u80fd\u306e\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u5927\u5bb9\u91cf\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u5b89\u5168\u304b\u3064\u52b9\u7387\u7684\u306b\u884c\u3046\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30de\u30eb\u30c1\u30d1\u30fc\u30c8\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { S3Client, CreateMultipartUploadCommand, UploadPartCommand, \n         CompleteMultipartUploadCommand, AbortMultipartUploadCommand } from \"@aws-sdk\/client-s3\";\n\nconst s3Client = new S3Client({ region: \"ap-northeast-1\" });\n\nasync function multipartUpload(bucketName, key, fileStream, partSize = 5242880) {\n    let uploadId;\n    const parts = [];\n\n    try {\n        \/\/ \u30de\u30eb\u30c1\u30d1\u30fc\u30c8\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u521d\u671f\u5316\n        const createCommand = new CreateMultipartUploadCommand({\n            Bucket: bucketName,\n            Key: key\n        });\n\n        const { UploadId } = await s3Client.send(createCommand);\n        uploadId = UploadId;\n\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u5206\u5272\u3057\u3066\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\n        let partNumber = 1;\n        let chunk;\n\n        while ((chunk = fileStream.read(partSize)) !== null) {\n            const uploadCommand = new UploadPartCommand({\n                Bucket: bucketName,\n                Key: key,\n                UploadId: uploadId,\n                PartNumber: partNumber,\n                Body: chunk\n            });\n\n            const { ETag } = await s3Client.send(uploadCommand);\n            parts.push({\n                PartNumber: partNumber,\n                ETag: ETag\n            });\n\n            partNumber++;\n        }\n\n        \/\/ \u30de\u30eb\u30c1\u30d1\u30fc\u30c8\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e\u5b8c\u4e86\n        const completeCommand = new CompleteMultipartUploadCommand({\n            Bucket: bucketName,\n            Key: key,\n            UploadId: uploadId,\n            MultipartUpload: { Parts: parts }\n        });\n\n        await s3Client.send(completeCommand);\n        console.log(\"\u30de\u30eb\u30c1\u30d1\u30fc\u30c8\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5b8c\u4e86\");\n\n    } catch (error) {\n        \/\/ \u30a8\u30e9\u30fc\u6642\u306f\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u4e2d\u6b62\n        if (uploadId) {\n            const abortCommand = new AbortMultipartUploadCommand({\n                Bucket: bucketName,\n                Key: key,\n                UploadId: uploadId\n            });\n            await s3Client.send(abortCommand);\n        }\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30d7\u30ed\u30b0\u30ec\u30b9\u8868\u793a\u4ed8\u304d\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { Upload } from \"@aws-sdk\/lib-storage\";\n\nasync function uploadWithProgress(bucketName, key, fileStream, fileSize) {\n    try {\n        const upload = new Upload({\n            client: s3Client,\n            params: {\n                Bucket: bucketName,\n                Key: key,\n                Body: fileStream\n            }\n        });\n\n        \/\/ \u30d7\u30ed\u30b0\u30ec\u30b9\u30a4\u30d9\u30f3\u30c8\u306e\u76e3\u8996\n        upload.on(\"httpUploadProgress\", (progress) =&gt; {\n            const percentage = Math.round((progress.loaded \/ fileSize) * 100);\n            console.log(`\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u9032\u6357: ${percentage}%`);\n        });\n\n        await upload.done();\n        console.log(\"\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5b8c\u4e86\");\n\n    } catch (error) {\n        console.error(\"\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">Lambda\u95a2\u6570\u306e\u30c7\u30d7\u30ed\u30a4\u3068\u7ba1\u7406\u306e\u81ea\u52d5\u5316<\/h3>\n\n\n\n<p>Lambda\u95a2\u6570\u306e\u7ba1\u7406\u3092\u81ea\u52d5\u5316\u3059\u308b\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Lambda\u95a2\u6570\u306e\u4f5c\u6210\u3068\u66f4\u65b0<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { LambdaClient, CreateFunctionCommand, UpdateFunctionCodeCommand, \n         PublishVersionCommand } from \"@aws-sdk\/client-lambda\";\nimport { readFileSync } from \"fs\";\nimport { zip } from \"zip-a-folder\";\n\nconst lambdaClient = new LambdaClient({ region: \"ap-northeast-1\" });\n\nasync function deployLambdaFunction(functionName, handlerFile, role) {\n    try {\n        \/\/ \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092ZIP\u5316\n        await zip(\".\/source\", \".\/function.zip\");\n        const zipFile = readFileSync(\".\/function.zip\");\n\n        try {\n            \/\/ \u65e2\u5b58\u306e\u95a2\u6570\u3092\u66f4\u65b0\n            const updateCommand = new UpdateFunctionCodeCommand({\n                FunctionName: functionName,\n                ZipFile: zipFile\n            });\n            await lambdaClient.send(updateCommand);\n            console.log(\"Lambda\u95a2\u6570\u3092\u66f4\u65b0\u3057\u307e\u3057\u305f\");\n\n        } catch (error) {\n            if (error.name === 'ResourceNotFoundException') {\n                \/\/ \u65b0\u898f\u4f5c\u6210\n                const createCommand = new CreateFunctionCommand({\n                    FunctionName: functionName,\n                    Runtime: \"nodejs18.x\",\n                    Role: role,\n                    Handler: handlerFile,\n                    Code: {\n                        ZipFile: zipFile\n                    },\n                    Description: \"Automatically deployed function\",\n                    Timeout: 30,\n                    MemorySize: 128,\n                    Publish: true\n                });\n\n                await lambdaClient.send(createCommand);\n                console.log(\"Lambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\");\n            } else {\n                throw error;\n            }\n        }\n\n        \/\/ \u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30d1\u30d6\u30ea\u30c3\u30b7\u30e5\n        const publishCommand = new PublishVersionCommand({\n            FunctionName: functionName,\n            Description: `Automated deployment ${new Date().toISOString()}`\n        });\n\n        const { Version } = await lambdaClient.send(publishCommand);\n        console.log(`\u30d0\u30fc\u30b8\u30e7\u30f3 ${Version} \u3092\u30d1\u30d6\u30ea\u30c3\u30b7\u30e5\u3057\u307e\u3057\u305f`);\n\n    } catch (error) {\n        console.error(\"\u30c7\u30d7\u30ed\u30a4\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">CloudWatch\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u76e3\u8996\u30b7\u30b9\u30c6\u30e0\u69cb\u7bc9<\/h3>\n\n\n\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30e1\u30c8\u30ea\u30af\u30b9\u3092\u76e3\u8996\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { CloudWatchClient, PutMetricDataCommand } from \"@aws-sdk\/client-cloudwatch\";\n\nconst cwClient = new CloudWatchClient({ region: \"ap-northeast-1\" });\n\nasync function recordMetrics(namespace, metricName, value, dimensions) {\n    try {\n        const command = new PutMetricDataCommand({\n            Namespace: namespace,\n            MetricData: [\n                {\n                    MetricName: metricName,\n                    Value: value,\n                    Unit: \"Count\",\n                    Dimensions: Object.entries(dimensions).map(([name, value]) =&gt; ({\n                        Name: name,\n                        Value: value\n                    })),\n                    Timestamp: new Date()\n                }\n            ]\n        });\n\n        await cwClient.send(command);\n        console.log(`\u30e1\u30c8\u30ea\u30af\u30b9 ${metricName} \u3092\u8a18\u9332\u3057\u307e\u3057\u305f`);\n\n    } catch (error) {\n        console.error(\"\u30e1\u30c8\u30ea\u30af\u30b9\u8a18\u9332\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30e1\u30c8\u30ea\u30af\u30b9\u76e3\u8996\u3068\u30a2\u30e9\u30fc\u30c8\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { PutMetricAlarmCommand } from \"@aws-sdk\/client-cloudwatch\";\n\nasync function createMetricAlarm(\n    alarmName,\n    namespace,\n    metricName,\n    threshold,\n    dimensions\n) {\n    try {\n        const command = new PutMetricAlarmCommand({\n            AlarmName: alarmName,\n            Namespace: namespace,\n            MetricName: metricName,\n            Threshold: threshold,\n            ComparisonOperator: \"GreaterThanThreshold\",\n            EvaluationPeriods: 2,\n            Period: 300, \/\/ 5\u5206\n            Statistic: \"Average\",\n            ActionsEnabled: true,\n            AlarmDescription: `Alarm when ${metricName} exceeds ${threshold}`,\n            Dimensions: Object.entries(dimensions).map(([name, value]) =&gt; ({\n                Name: name,\n                Value: value\n            })),\n            \/\/ SNS\u30c8\u30d4\u30c3\u30af\u3078\u306e\u901a\u77e5\u8a2d\u5b9a\n            AlarmActions: [\"arn:aws:sns:region:account-id:topic-name\"]\n        });\n\n        await cwClient.send(command);\n        console.log(`\u30a2\u30e9\u30fc\u30e0 ${alarmName} \u3092\u4f5c\u6210\u3057\u307e\u3057\u305f`);\n\n    } catch (error) {\n        console.error(\"\u30a2\u30e9\u30fc\u30e0\u4f5c\u6210\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u7d71\u5408\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MonitoringSystem {\n    constructor(namespace) {\n        this.namespace = namespace;\n        this.metrics = new Map();\n    }\n\n    \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n    async trackMetric(name, value, dimensions = {}) {\n        await recordMetrics(this.namespace, name, value, dimensions);\n\n        \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u5c65\u6b74\u3092\u4fdd\u6301\n        if (!this.metrics.has(name)) {\n            this.metrics.set(name, []);\n        }\n        this.metrics.get(name).push({ value, timestamp: new Date() });\n    }\n\n    \/\/ \u30a2\u30e9\u30fc\u30c8\u306e\u8a2d\u5b9a\n    async setupAlerts(config) {\n        for (const [metricName, settings] of Object.entries(config)) {\n            await createMetricAlarm(\n                `${this.namespace}-${metricName}-Alert`,\n                this.namespace,\n                metricName,\n                settings.threshold,\n                settings.dimensions\n            );\n        }\n    }\n\n    \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u96c6\u8a08\n    getMetricStats(name, minutes = 60) {\n        const metrics = this.metrics.get(name) || [];\n        const cutoff = new Date(Date.now() - minutes * 60000);\n\n        const recentMetrics = metrics.filter(m =&gt; m.timestamp &gt; cutoff);\n        const values = recentMetrics.map(m =&gt; m.value);\n\n        return {\n            average: values.reduce((a, b) =&gt; a + b, 0) \/ values.length,\n            max: Math.max(...values),\n            min: Math.min(...values),\n            count: values.length\n        };\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nconst monitoring = new MonitoringSystem(\"MyApplication\");\n\n\/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u8a18\u9332\nawait monitoring.trackMetric(\"APILatency\", 150, {\n    endpoint: \"\/api\/users\",\n    method: \"GET\"\n});\n\n\/\/ \u30a2\u30e9\u30fc\u30c8\u8a2d\u5b9a\nawait monitoring.setupAlerts({\n    APILatency: {\n        threshold: 200,\n        dimensions: { service: \"UserAPI\" }\n    }\n});<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u5fc5\u8981\u3068\u306a\u308b\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u9069\u5207\u306a\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3001\u30ed\u30b0\u8a18\u9332\u3001\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3092\u7d44\u307f\u8fbc\u3080\u3053\u3068\u3067\u3001\u672c\u756a\u74b0\u5883\u3067\u904b\u7528\u53ef\u80fd\u306a\u5805\u7262\u306a\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-20\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">\u8a8d\u8a3c\u60c5\u5831\u306e\u5b89\u5168\u306a\u7ba1\u7406\u65b9\u6cd5<\/h3>\n\n\n\n<p>AWS SDK\u3092\u4f7f\u7528\u3059\u308b\u969b\u306e\u8a8d\u8a3c\u60c5\u5831\u7ba1\u7406\u306b\u3064\u3044\u3066\u3001\u30bb\u30ad\u30e5\u30a2\u306a\u5b9f\u88c5\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u74b0\u5883\u5909\u6570\u3092\u4f7f\u7528\u3057\u305f\u8a8d\u8a3c\u60c5\u5831\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { fromEnv } from \"@aws-sdk\/credential-providers\";\nimport { S3Client } from \"@aws-sdk\/client-s3\";\n\n\/\/ \u74b0\u5883\u5909\u6570\u304b\u3089\u8a8d\u8a3c\u60c5\u5831\u3092\u5b89\u5168\u306b\u8aad\u307f\u8fbc\u3080\nconst client = new S3Client({\n    credentials: fromEnv(),\n    region: \"ap-northeast-1\"\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>IAM\u30ed\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u305f\u8a8d\u8a3c<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { fromInstanceMetadata } from \"@aws-sdk\/credential-providers\";\n\nconst client = new S3Client({\n    credentials: fromInstanceMetadata(),\n    region: \"ap-northeast-1\"\n});<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u4e00\u6642\u7684\u306a\u8a8d\u8a3c\u60c5\u5831\u306e\u4f7f\u7528<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { STSClient, AssumeRoleCommand } from \"@aws-sdk\/client-sts\";\n\nasync function getTemporaryCredentials(roleArn) {\n    const stsClient = new STSClient({ region: \"ap-northeast-1\" });\n\n    try {\n        const command = new AssumeRoleCommand({\n            RoleArn: roleArn,\n            RoleSessionName: `temp-session-${Date.now()}`,\n            DurationSeconds: 3600 \/\/ 1\u6642\u9593\n        });\n\n        const response = await stsClient.send(command);\n\n        return {\n            accessKeyId: response.Credentials.AccessKeyId,\n            secretAccessKey: response.Credentials.SecretAccessKey,\n            sessionToken: response.Credentials.SessionToken,\n            expiration: response.Credentials.Expiration\n        };\n    } catch (error) {\n        console.error(\"\u4e00\u6642\u7684\u8a8d\u8a3c\u60c5\u5831\u306e\u53d6\u5f97\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u7ba1\u7406\u30b5\u30fc\u30d3\u30b9\u306e\u5229\u7528<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { SecretsManagerClient, GetSecretValueCommand } \n    from \"@aws-sdk\/client-secrets-manager\";\n\nasync function getCredentialsFromSecretManager(secretName) {\n    const client = new SecretsManagerClient({ region: \"ap-northeast-1\" });\n\n    try {\n        const command = new GetSecretValueCommand({\n            SecretId: secretName\n        });\n\n        const response = await client.send(command);\n        const secret = JSON.parse(response.SecretString);\n\n        return {\n            accessKeyId: secret.AWS_ACCESS_KEY_ID,\n            secretAccessKey: secret.AWS_SECRET_ACCESS_KEY\n        };\n    } catch (error) {\n        console.error(\"\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u53d6\u5f97\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">\u63a5\u7d9a\u30d7\u30fc\u30eb\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u306e\u63a5\u7d9a\u7ba1\u7406\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>HTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { S3Client } from \"@aws-sdk\/client-s3\";\nimport { NodeHttpHandler } from \"@aws-sdk\/node-http-handler\";\nimport https from \"https\";\n\n\/\/ \u30ab\u30b9\u30bf\u30e0HTTP\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306e\u8a2d\u5b9a\nconst agent = new https.Agent({\n    keepAlive: true, \/\/ \u63a5\u7d9a\u306e\u518d\u5229\u7528\u3092\u6709\u52b9\u5316\n    maxSockets: 50,  \/\/ \u540c\u6642\u63a5\u7d9a\u6570\u306e\u5236\u9650\n    timeout: 5000    \/\/ \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\n});\n\nconst client = new S3Client({\n    region: \"ap-northeast-1\",\n    requestHandler: new NodeHttpHandler({\n        httpAgent: agent,\n        httpsAgent: agent\n    })\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { DynamoDBClient } from \"@aws-sdk\/client-dynamodb\";\nimport NodeCache from \"node-cache\";\n\nclass CachedDynamoDBClient {\n    constructor(options = {}) {\n        this.client = new DynamoDBClient({ region: \"ap-northeast-1\" });\n        this.cache = new NodeCache({\n            stdTTL: options.ttl || 300, \/\/ \u30c7\u30d5\u30a9\u30eb\u30c85\u5206\n            checkperiod: 60\n        });\n    }\n\n    async getItem(params) {\n        const cacheKey = this.generateCacheKey(params);\n        const cachedItem = this.cache.get(cacheKey);\n\n        if (cachedItem) {\n            console.log(\"\u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\");\n            return cachedItem;\n        }\n\n        const response = await this.client.send(new GetItemCommand(params));\n        this.cache.set(cacheKey, response.Item);\n\n        return response.Item;\n    }\n\n    generateCacheKey(params) {\n        return `${params.TableName}:${JSON.stringify(params.Key)}`;\n    }\n\n    invalidateCache(params) {\n        const cacheKey = this.generateCacheKey(params);\n        this.cache.del(cacheKey);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">\u30b3\u30b9\u30c8\u6700\u9069\u5316\u306e\u305f\u3081\u306e SDK \u8a2d\u5b9a<\/h3>\n\n\n\n<p>AWS SDK\u306e\u4f7f\u7528\u306b\u3088\u308b\u30b3\u30b9\u30c8\u3092\u6700\u9069\u5316\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u6700\u9069\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { DynamoDBClient } from \"@aws-sdk\/client-dynamodb\";\nimport { BatchWriteCommand } from \"@aws-sdk\/lib-dynamodb\";\n\nasync function batchWriteWithRetry(tableName, items, maxBatchSize = 25) {\n    const client = new DynamoDBClient({ region: \"ap-northeast-1\" });\n\n    \/\/ \u30d0\u30c3\u30c1\u30b5\u30a4\u30ba\u3067\u5206\u5272\n    const batches = [];\n    for (let i = 0; i &lt; items.length; i += maxBatchSize) {\n        batches.push(items.slice(i, i + maxBatchSize));\n    }\n\n    const results = [];\n\n    for (const batch of batches) {\n        const command = new BatchWriteCommand({\n            RequestItems: {\n                [tableName]: batch.map(item =&gt; ({\n                    PutRequest: { Item: item }\n                }))\n            }\n        });\n\n        try {\n            const response = await client.send(command);\n            results.push(response);\n\n            \/\/ \u672a\u51e6\u7406\u9805\u76ee\u306e\u518d\u8a66\u884c\n            if (Object.keys(response.UnprocessedItems).length &gt; 0) {\n                console.warn(\"\u672a\u51e6\u7406\u9805\u76ee\u304c\u3042\u308a\u307e\u3059\u3002\u518d\u8a66\u884c\u3057\u307e\u3059\u3002\");\n                \/\/ \u518d\u8a66\u884c\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\n            }\n        } catch (error) {\n            console.error(\"\u30d0\u30c3\u30c1\u66f8\u304d\u8fbc\u307f\u30a8\u30e9\u30fc:\", error);\n            throw error;\n        }\n    }\n\n    return results;\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u8ee2\u9001\u306e\u6700\u9069\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { S3Client, GetObjectCommand } from \"@aws-sdk\/client-s3\";\nimport { createReadStream } from \"fs\";\nimport zlib from \"zlib\";\n\n\/\/ \u5727\u7e2e\u8ee2\u9001\u306e\u5b9f\u88c5\nasync function uploadCompressedFile(bucketName, key, filePath) {\n    const client = new S3Client({ region: \"ap-northeast-1\" });\n\n    try {\n        const fileStream = createReadStream(filePath);\n        const compressedStream = fileStream.pipe(zlib.createGzip());\n\n        const command = new PutObjectCommand({\n            Bucket: bucketName,\n            Key: key,\n            Body: compressedStream,\n            ContentEncoding: 'gzip'\n        });\n\n        await client.send(command);\n        console.log(\"\u5727\u7e2e\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5b8c\u4e86\");\n\n    } catch (error) {\n        console.error(\"\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30a8\u30e9\u30fc:\", error);\n        throw error;\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u4f7f\u7528\u306e\u6700\u9069\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ResourceOptimizer {\n    constructor() {\n        this.clients = new Map();\n        this.maxIdleTime = 300000; \/\/ 5\u5206\n    }\n\n    getClient(service, region) {\n        const key = `${service}-${region}`;\n\n        if (!this.clients.has(key)) {\n            const ClientClass = require(`@aws-sdk\/client-${service}`)[`${service}Client`];\n            const client = new ClientClass({ region });\n\n            this.clients.set(key, {\n                client,\n                lastUsed: Date.now()\n            });\n\n            return client;\n        }\n\n        const entry = this.clients.get(key);\n        entry.lastUsed = Date.now();\n        return entry.client;\n    }\n\n    \/\/ \u672a\u4f7f\u7528\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\n    cleanup() {\n        const now = Date.now();\n\n        for (const [key, entry] of this.clients.entries()) {\n            if (now - entry.lastUsed &gt; this.maxIdleTime) {\n                this.clients.delete(key);\n            }\n        }\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nconst optimizer = new ResourceOptimizer();\nconst s3Client = optimizer.getClient('s3', 'ap-northeast-1');\n\n\/\/ \u5b9a\u671f\u7684\u306a\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\nsetInterval(() =&gt; optimizer.cleanup(), 60000);<\/pre>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u6700\u9069\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u9069\u5207\u306a\u30da\u30fc\u30b8\u30cd\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u4e0d\u8981\u306a\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u524a\u6e1b<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u63a5\u7d9a\u30d7\u30fc\u30eb\u306e\u9069\u5207\u306a\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u76e3\u8996<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b3\u30b9\u30c8\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u8ee2\u9001\u91cf\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u306e\u52b9\u7387\u7684\u306a\u4f7f\u7528<\/li>\n\n\n\n<li>\u9069\u5207\u306a\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u30bb\u30ad\u30e5\u30a2\u3067\u52b9\u7387\u7684\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-24\">AWS SDK for JavaScript\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u30ac\u30a4\u30c9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-25\">\u4e00\u822c\u7684\u306a\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n\n\n\n<p>AWS SDK\u3092\u4f7f\u7528\u3059\u308b\u969b\u306b\u3088\u304f\u906d\u9047\u3059\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8a8d\u8a3c\u95a2\u9023\u306e\u30a8\u30e9\u30fc<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u554f\u984c: AccessDenied\n\/\/ \u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u4f8b: \"User: arn:aws:iam::123456789012:user\/developer is not authorized to perform: s3:PutObject on resource: arn:aws:s3:::my-bucket\/*\"\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd51: IAM\u30dd\u30ea\u30b7\u30fc\u306e\u78ba\u8a8d\nconst iamPolicy = {\n    Version: \"2012-10-17\",\n    Statement: [{\n        Effect: \"Allow\",\n        Action: [\"s3:PutObject\", \"s3:GetObject\"],\n        Resource: \"arn:aws:s3:::my-bucket\/*\"\n    }]\n};\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd52: \u8a8d\u8a3c\u60c5\u5831\u306e\u78ba\u8a8d\nimport { fromIni } from \"@aws-sdk\/credential-providers\";\n\nconst client = new S3Client({\n    credentials: fromIni({ profile: 'development' }),\n    region: \"ap-northeast-1\"\n});\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd53: AssumeRole\u4f7f\u7528\u6642\u306e\u6a29\u9650\u78ba\u8a8d\nasync function verifyAssumeRolePermissions(roleArn) {\n    const sts = new STSClient({ region: \"ap-northeast-1\" });\n    try {\n        const command = new GetCallerIdentityCommand({});\n        const response = await sts.send(command);\n        console.log(\"\u73fe\u5728\u306e\u5b9f\u884c\u30ed\u30fc\u30eb:\", response.Arn);\n\n        \/\/ \u30ed\u30fc\u30eb\u306e\u6a29\u9650\u3092\u78ba\u8a8d\n        const iamClient = new IAMClient({ region: \"ap-northeast-1\" });\n        const getRoleCommand = new GetRoleCommand({ RoleName: roleArn.split(\"\/\")[1] });\n        const roleInfo = await iamClient.send(getRoleCommand);\n        console.log(\"\u30ed\u30fc\u30eb\u306e\u6a29\u9650:\", roleInfo.Role.AssumeRolePolicyDocument);\n    } catch (error) {\n        console.error(\"\u6a29\u9650\u78ba\u8a8d\u30a8\u30e9\u30fc:\", error);\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u95a2\u9023\u306e\u30a8\u30e9\u30fc<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u554f\u984c: TimeoutError\n\/\/ \u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u4f8b: \"Connect timeout of 5000ms exceeded\"\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd51: \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u306e\u8abf\u6574\nconst client = new S3Client({\n    region: \"ap-northeast-1\",\n    requestHandler: new NodeHttpHandler({\n        connectionTimeout: 10000, \/\/ 10\u79d2\n        socketTimeout: 10000\n    })\n});\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd52: \u30ea\u30c8\u30e9\u30a4\u8a2d\u5b9a\u306e\u6700\u9069\u5316\nconst client = new S3Client({\n    region: \"ap-northeast-1\",\n    maxAttempts: 5,\n    retryStrategy: new StandardRetryStrategy(() =&gt; Promise.resolve(3000))\n});\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd53: \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u8a3a\u65ad\u30c4\u30fc\u30eb\nasync function diagnoseNetworkIssues(endpoint) {\n    const dns = require('dns').promises;\n    try {\n        \/\/ DNS\u89e3\u6c7a\u306e\u78ba\u8a8d\n        const addresses = await dns.resolve4(endpoint);\n        console.log(\"DNS\u89e3\u6c7a\u6210\u529f:\", addresses);\n\n        \/\/ TCP\u63a5\u7d9a\u30c6\u30b9\u30c8\n        const net = require('net');\n        const socket = new net.Socket();\n        await new Promise((resolve, reject) =&gt; {\n            socket.connect(443, endpoint, () =&gt; {\n                console.log(\"TCP\u63a5\u7d9a\u6210\u529f\");\n                socket.end();\n                resolve();\n            });\n            socket.on('error', reject);\n        });\n    } catch (error) {\n        console.error(\"\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u8a3a\u65ad\u30a8\u30e9\u30fc:\", error);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-26\">\u30c7\u30d0\u30c3\u30b0\u30c4\u30fc\u30eb\u3068\u30ed\u30b0\u53ce\u96c6\u306e\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u52b9\u679c\u7684\u306a\u30c7\u30d0\u30c3\u30b0\u3068\u30ed\u30b0\u53ce\u96c6\u306e\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9\u306e\u6709\u52b9\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { Logger } from \"@aws-sdk\/types\";\n\n\/\/ \u30ab\u30b9\u30bf\u30e0\u30ed\u30ac\u30fc\u306e\u5b9f\u88c5\nconst debugLogger: Logger = {\n    debug: (...args) =&gt; console.debug(...args),\n    info: (...args) =&gt; console.info(...args),\n    warn: (...args) =&gt; console.warn(...args),\n    error: (...args) =&gt; console.error(...args)\n};\n\nconst client = new S3Client({\n    region: \"ap-northeast-1\",\n    logger: debugLogger,\n    \/\/ HTTP\/HTTPS\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30c7\u30d0\u30c3\u30b0\n    requestHandler: new NodeHttpHandler({\n        debug: true\n    })\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u8a73\u7d30\u306a\u30ed\u30b0\u53ce\u96c6\u30b7\u30b9\u30c6\u30e0<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class SDKLogger {\n    constructor() {\n        this.logs = [];\n        this.startTime = Date.now();\n    }\n\n    logRequest(request) {\n        this.logs.push({\n            timestamp: new Date().toISOString(),\n            type: 'request',\n            service: request.input.constructor.name,\n            params: request.input,\n            elapsed: Date.now() - this.startTime\n        });\n    }\n\n    logResponse(response) {\n        this.logs.push({\n            timestamp: new Date().toISOString(),\n            type: 'response',\n            status: response.$metadata?.httpStatusCode,\n            data: response,\n            elapsed: Date.now() - this.startTime\n        });\n    }\n\n    logError(error) {\n        this.logs.push({\n            timestamp: new Date().toISOString(),\n            type: 'error',\n            name: error.name,\n            message: error.message,\n            stack: error.stack,\n            elapsed: Date.now() - this.startTime\n        });\n    }\n\n    export() {\n        return {\n            logs: this.logs,\n            summary: {\n                totalRequests: this.logs.filter(l =&gt; l.type === 'request').length,\n                totalErrors: this.logs.filter(l =&gt; l.type === 'error').length,\n                averageResponseTime: this.calculateAverageResponseTime()\n            }\n        };\n    }\n\n    calculateAverageResponseTime() {\n        const responses = this.logs.filter(l =&gt; l.type === 'response');\n        if (responses.length === 0) return 0;\n        return responses.reduce((acc, curr) =&gt; acc + curr.elapsed, 0) \/ responses.length;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-27\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u554f\u984c\u306e\u8a3a\u65ad\u3068\u6539\u5584<\/h3>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u3092\u7279\u5b9a\u3057\u3001\u6539\u5584\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8a08\u6e2c\u30c4\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class PerformanceMonitor {\n    constructor() {\n        this.metrics = new Map();\n    }\n\n    async measureOperation(name, operation) {\n        const start = process.hrtime.bigint();\n        try {\n            const result = await operation();\n            const end = process.hrtime.bigint();\n            this.recordMetric(name, end - start);\n            return result;\n        } catch (error) {\n            const end = process.hrtime.bigint();\n            this.recordMetric(name, end - start, false);\n            throw error;\n        }\n    }\n\n    recordMetric(name, duration, success = true) {\n        if (!this.metrics.has(name)) {\n            this.metrics.set(name, {\n                count: 0,\n                totalTime: 0n,\n                failures: 0,\n                min: duration,\n                max: duration\n            });\n        }\n\n        const metric = this.metrics.get(name);\n        metric.count++;\n        metric.totalTime += duration;\n        if (!success) metric.failures++;\n        metric.min = duration &lt; metric.min ? duration : metric.min;\n        metric.max = duration &gt; metric.max ? duration : metric.max;\n    }\n\n    getReport() {\n        const report = {};\n        for (const [name, metric] of this.metrics.entries()) {\n            report[name] = {\n                averageMs: Number(metric.totalTime) \/ metric.count \/ 1_000_000,\n                minMs: Number(metric.min) \/ 1_000_000,\n                maxMs: Number(metric.max) \/ 1_000_000,\n                successRate: (metric.count - metric.failures) \/ metric.count * 100,\n                totalCalls: metric.count\n            };\n        }\n        return report;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\nconst monitor = new PerformanceMonitor();\n\nasync function performOperationWithMonitoring() {\n    const s3Client = new S3Client({ region: \"ap-northeast-1\" });\n\n    await monitor.measureOperation(\"listBuckets\", async () =&gt; {\n        const command = new ListBucketsCommand({});\n        return await s3Client.send(command);\n    });\n\n    console.log(monitor.getReport());\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u691c\u51fa<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MemoryLeakDetector {\n    constructor(thresholdMB = 100) {\n        this.thresholdMB = thresholdMB;\n        this.baselineMemory = process.memoryUsage().heapUsed;\n        this.checkInterval = setInterval(() =&gt; this.checkMemoryUsage(), 60000);\n    }\n\n    checkMemoryUsage() {\n        const currentMemory = process.memoryUsage().heapUsed;\n        const diffMB = (currentMemory - this.baselineMemory) \/ 1024 \/ 1024;\n\n        if (diffMB &gt; this.thresholdMB) {\n            console.warn(`\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c${diffMB.toFixed(2)}MB\u5897\u52a0\u3057\u307e\u3057\u305f`);\n            console.warn('\u30d2\u30fc\u30d7\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u53d6\u5f97\u3092\u63a8\u5968\u3057\u307e\u3059');\n        }\n    }\n\n    stop() {\n        clearInterval(this.checkInterval);\n    }\n}<\/pre>\n\n\n\n<p>\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4f53\u7cfb\u7684\u306a\u30a2\u30d7\u30ed\u30fc\u30c1<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u8a73\u7d30\u306a\u5206\u6790<\/li>\n\n\n\n<li>\u74b0\u5883\u5909\u6570\u3068AWS\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u63a5\u7d9a\u306e\u691c\u8a3c<\/li>\n\n\n\n<li>IAM\u6a29\u9650\u306e\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ed\u30b0\u5206\u6790\u306e\u91cd\u8981\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8a73\u7d30\u306a\u30ed\u30b0\u53ce\u96c6\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u7279\u5b9a<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6307\u6a19\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u554f\u984c\u306e\u518d\u73fe\u6027\u306e\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e88\u9632\u7684\u63aa\u7f6e<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b9a\u671f\u7684\u306a\u76e3\u8996\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30a2\u30e9\u30fc\u30c8\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6307\u6a19\u306e\u8ffd\u8de1<\/li>\n\n\n\n<li>\u81ea\u52d5\u5316\u3055\u308c\u305f\u30c6\u30b9\u30c8\u306e\u5b9f\u65bd<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u624b\u6cd5\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u554f\u984c\u306e\u65e9\u671f\u767a\u898b\u3068\u52b9\u7387\u7684\u306a\u89e3\u6c7a\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":{"0":"post-2248","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-aws","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2248"}],"version-history":[{"count":1,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2248\/revisions"}],"predecessor-version":[{"id":2249,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2248\/revisions\/2249"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}